Can you not add a Bitmap to the sprite ?
So (entirely off the top of my head) :
function imgLoaded(e:Event):void{
var eventImg:Bitmap = new Bitmap( imgLdr.content as BitmapData)
eventImg.smoothing = true;
eventImg.setActualSize(300, 200);
sheet.addChild(eventImg);
}
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Jayson
Sent: 30 October 2008 03:49
To: [email protected]
Subject: [flexcoders] Loading an image dynamically and making it a
BitmapAsset
I am using BitmapAssets to add to a sprite which is printed using
PrintJob.
[Embed(source="images/logo.png")]
[Bindable]
public var logo:Class;
...
var bitmapImg:BitmapAsset = new logo() as BitmapAsset;
bitmapImg.smoothing = true;
bitmapImg.setActualSize(500, 42);
sheet.addChild(bitmapImg);
This works fine when the image to be added is embedded. Some images I
need to add dynamically. How would I do this?
I've tried using a Loader and doing something like this:
var imgLdr:Loader = new Loader(imgURLReq);
imgLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);
function imgLoaded(e:Event):void{
var eventImg:BitmapAsset = new BitmapAsset;
eventImg.bitmapData = imgLdr.content as BitmapData
eventImg.smoothing = true;
eventImg.setActualSize(300, 200);
sheet.addChild(eventImg);
}
I think I need to do something similar to the static method by loading
the image with a Loader and casting it as a Class, but this is not
working out for me.
Any ideas?
Thanks!
Jayson
______________________________________________________________________
This communication is from Primal Pictures Ltd., a company registered in
England and Wales with registration No. 02622298 and registered office: 4th
Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT
registration No. 648874577.
This e-mail is confidential and may be privileged. It may be read, copied and
used only by the intended recipient. If you have received it in error, please
contact the sender immediately by return e-mail or by telephoning +44(0)20 7637
1010. Please then delete the e-mail and do not disclose its contents to any
person.
This email has been scanned for Primal Pictures by the MessageLabs Email
Security System.
______________________________________________________________________