See the following for understanding what I’m talking about
http://henryjones.us/articles/using-the-as3-jpeg-encoder
http://code.google.com/p/as3corelib/
Now, is there just no way I can get the JPGEncoder to work with a UILoader object?
I’m attempting to load a swf file that is a flv player of mine. I then want to make a screen shot when I want of the playing flv. I thought this would be a rockin’ easy way.
Example Script (some objects are on the stage)
import com.adobe.images.JPGEncoder;
import flash.net.navigateToURL;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.net.URLVariables;
import fl.containers.UILoader;
import fl.controls.ComboBox;
var capture:MovieClip;
holder._loader.source = "#################"; // FLV PLAYER URL REMOVED Just load any swf file.
holder._loader.setSize(330,270);
holder._loader.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(event:Event):void {
capture=holder._loader.content;
}
function createJPG(m:MovieClip, q:Number, fileName:String)
{
statusArea.htmlText += 'SNAGGED
';
var jpgSource:BitmapData = new BitmapData (m.width, m.height,true);
//BitmapData(width:int, height:int, transparent:Boolean = true, fillColor:uint = 0xFFFFFFFF)
//FOR PNGs//BitmapData(width:int, height:int, transparent:Boolean = true, fillColor:uint = 0xFFFFFFFF)
jpgSource.draw(m);
var jpgEncoder:JPGEncoder = new JPGEncoder(q);
var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);
var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");
//Make sure to use the correct path to jpg_encoder_download.php
var jpgURLRequest:URLRequest = new URLRequest ("jpg_encoder_download.php?name=" + fileName + ".jpg");
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
var jpgURLLoader:URLLoader = new URLLoader();
navigateToURL(jpgURLRequest, "_blank");
}
//Call the function and pass in the movieclip that you want to encode,
//the quality, and the file name
btn_snag.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:MouseEvent){
statusArea.htmlText += 'btn_snag clicked
';
if(cb.selectedItem.data == 2){
createJPG(capture, 90, filename_input.text);
}else{
createJPG(shape_mc, 90, filename_input.text);
}
}
var cb:ComboBox = new ComboBox();
cb.move(395, 19);
addChild(cb);
cb.addItem( { label: "shape", data:1 } );
cb.addItem( { label: "flv", data:2 } );
cb.addEventListener(Event.CHANGE, cardSelected);
function cardSelected(e:Event):void {
statusArea.htmlText += "You have selected: "+cb.selectedItem.label;
}