Ciao
ti riporto di seguito tutto il codice :
codice:
import it.sephiroth.mloaderWindow
import it.sephiroth.PrintScreen
var loader:mloaderWindow = this.createClassObject(mloaderWindow, "loader", 10, {_x:-1000, _y:-1000})
loader.setStyle("borderColor", 0x006699)
var listener:Object = new Object();
// copy in progress...
listener.onProgress = function(target:MovieClip, loaded:Number, total:Number){
var perc = Math.round((loaded/total)*100)
loader.label = "computing... " + perc + "%"
loader.value = perc
};
// copy is complete, send the result LoadVars to PHP
listener.onComplete = function(target:MovieClip, load_var:LoadVars){
loader.label = "sending to php...";
load_var.send("/pixels.php", "_blank", "POST");
loader.close();
getURL("javascript:window.location.reload();");
};
createEmptyMovieClip("Line",1);
Line.lineStyle(1,0x000000,100);
onMouseDown = function (){
if (_ymouse>0 && _ymouse<500) {
Line.moveTo(_xmouse, _ymouse);
} else {
null;
}
onMouseMove = function (){
if (_ymouse>0 && _ymouse<500) {
Line.lineTo(_xmouse, _ymouse);
} else {
null;
}
}
}
onMouseUp=function()
{
onMouseMove=null;
}
// clear the drawing
erase_mc.onRelease = function()
{
createEmptyMovieClip("Line", 1);
Line.lineStyle(1, 0x000000, 100);
Line.beginFill(0x000000, 100);
Line.moveTo(0, 0);
Line.moveTo(0, 180);
Line.moveTo(350, 180);
Line.moveTo(350, 0);
Line.moveTo(0, 0);
Line.endFill();
};
// preme tasto salva
save_btn.onRelease = function()
{
print_me();
};
function print_me(){
Line.pause() // first pause the playing video
pn = new PrintScreen(); // initialize the PrintScreen class
pn.addListener( listener ); // assign a listener
pn.print(_root, 0, 0, 600, 500) // copy the _root
loader.label = "computing... 0%"
loader.open(true, true, true); // open a loader
}
In sostanza il listener riceve segnali dalla printscreen sul movieclip, quando è completa invia il tutto a una pagina PHP.
Ho utilizzato adesso il metodo SEND invece di SENDANDLOAD in quanto con quest'ultimo non mi si apre il nuovo tab ... o forse dovrei aggiungere qualcos'altro per farlo aprire ...