Load embed image in Loader

rfedericoni
rfedericoni used Ask the Experts™
on
How can I load embed image (jpg,gif,png, bmp) in a Loader?
I tried with the code in attach but it doesn't work?
[Bindable]
[Embed(source="../images/MB1.png")]
private var bmp:Class;
 
private function LoadURL():void
{
	var myBitmap:BitmapData = new bmp().bitmapData;
	var pixels:ByteArray = myBitmap.getPixels( new Rectangle(0,0,myBitmap.width,myBitmap.height) );
           
        loader.loadBytes(pixels);
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009

Commented:
don't know if this post from the friends at kirupa helps

http://www.kirupa.com/forum/showthread.php?p=2390556
i havent gone beyond hello world in flex yet (no time!!)
[Bindable]
[Embed(source="../images/MB1.png")]
private var bmp:Class;


                        var asset:BitmapAsset = new bmp() as BitmapAsset;

                        var ba:ByteArray = new ByteArray();
                        ba.writeBytes( new JPEGEncoder().encode(asset.bitmapData));
                         
                        var l:Loader = new Loader();
                        l.loadBytes( ba);

Author

Commented:
It's slow to load but it works..

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial