Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If your app is online, you would need a server side script to create and save the image.</p> <p>Basically the code could be as follows:</p> <pre><code>var request:URLRequest = new URLRequest( mailLoc ); request.contentType = 'application/octet-stream'; request.method = URLRequestMethod.POST; request.data = bArray; var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, MailCompleteHandler); loader.addEventListener( IOErrorEvent.IO_ERROR, _onImageError ); try { loader.load(request); } catch(error:Error) { trace("Unable to load URL"); } private function _onImageError(e:IOErrorEvent):void { trace("IOErrorEvent: ",e.type," : ",e.text) } </code></pre> <p>On the server side, php code:</p> <pre><code>//bindary data. $image_bytes = $GLOBALS["HTTP_RAW_POST_DATA"]; //change to whatever works for you $file_name = "testfile.jpg"; $file_path = "../uploads/$file_name"; $file = fopen( $file_path, 'w+' ); if ( !fwrite( $file, $image_bytes ) ) { return "Error writing to file: $file"; } fclose( $file ); </code></pre> <p>You can check read this to get more info:</p> <ul> <li><a href="http://designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed-saving-images-from-flash/" rel="nofollow">Save php</a></li> <li><a href="http://www.adobe.com/devnet/flash/articles/saving_flash_graphics.html" rel="nofollow">Saving flash graphics</a></li> </ul> <p>[EDIT] Capturing the bitmapdata:</p> <pre><code>//loader should be your loader instance displaying your graphic. var snapshot:BitmapData = capture(loader); var result:Bitmap = new Bitmap( snapshoot ); public function capture( target:DisplayObject ):BitmapData { var rect:Object = target.getBounds( target ); var width:Number = rect.width; var height:Number = rect.height; var bitmap:BitmapData = new BitmapData( width+1 , height+1, true, 0x00000000 ); var matrix:Matrix = new Matrix(); matrix.translate( -rect.x , -rect.y ); bitmap.draw( target , matrix ); return bitmap; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload