Published on : 02.05.2010 Category : PHP/FLASH Viewed : 44 times.
Now let's take a look at the flash file will use this "PrintScreen" class:
Code:
import it.sephiroth.mloaderWindow import it.sephiroth.PrintScreen
var loader:mloaderWindow = this.createClassObject(mloaderWindow, "loader", 10, {_x:-1000, _y:-1000}) loader.setStyle("borderColor", 0x006699)
// listener which receives the broadcast message // from the PrintScreen class 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("files/pixels.php", "_blank", "POST") loader.close() }
/** * Print Button has been clicked */ function print_me(){ video_mc.pause() // first pause the playing video pn = new PrintScreen(); // initialize the PrintScreen class pn.addListener( listener ); // assign a listener pn.print(_root, 0, 0, 500, 210) // copy the _root loader.label = "computing... 0%" loader.open(true, true, true); // open a loader }
there's nothing particular to say here.. Once the "print" button is clicked call the print_me() function. Stop the playing video, in order to copy the current video frame. Initialize the PrintScreen class and assign a listener which will receive all the broadcaster messages. I used pn.print(_root, 0,0, 500, 210) in order to print all the contents in _root.
Once the process is completed send the LoadVars object, which is returned by the onComplete function, to PHP using the POST method ( the posted Content-length is: 563024 )
|