Sorry .... error in it.... try the code below instead....
private var bitmapDataCopy:BitmapData;
private var sourceBitmap:BitmapData;
private function init():void {
var imgLoad:Loader=new Loader();
imgLoad.contentLoaderInfo.addEventListener(Event.COMPLETE,init2);
imgLoad.load(new URLRequest("assets/imagename.png"));
}
private function init2(e:Event):void {
sourceBitmap = e.target.content.bitmapData as BitmapData;
bitmapDataCopy = sourceBitmap.clone();
}
On Sun, May 18, 2008 at 4:55 PM, Allan Pichler <[EMAIL PROTECTED]> wrote:
> I believe this should work.....
>
> private var bitmapDataCopy:BitmapData;
> private var sourceBitmap:BitmapData;
>
> private function init():void {
> var imgLoad:Loader=new Loader();
> imgLoad.contentLoaderInfo.addEventListener(Event.COMPLETE,init2);
> imgLoad.load(new URLRequest("assets/imagename.png"));
> }
>
> private function init2(e:Event):void {
> sourceBitmap = e.target.content.bitmapData as BitmapData;
> bitmapDataCopy = sourceImage.clone();
> }
>
> On Sat, May 17, 2008 at 8:41 PM, Alex Harui <[EMAIL PROTECTED]> wrote:
>
>> SWFLoader doesn't get going until you addChild it. If you use
>> flash.display.Loader, you might be able to load w/o addChild
>>
>> ------------------------------
>> *From:* [email protected] [mailto:[EMAIL PROTECTED] *On
>> Behalf Of *flexawesome
>> *Sent:* Saturday, May 17, 2008 3:16 PM
>> *To:* [email protected]
>> *Subject:* [flexcoders] Re: a simple question of BitmapData
>>
>>
>> Hi there, I have updated the code ( enabled line5 ) and get the
>> duplicate copy of gif file.
>>
>> Is there a way to prevent to use addChild but still can get the copy
>> of the image?
>>
>> Cheers
>>
>> http://www.privatepaste.com/29lCTCERRY
>>
>> --- In [email protected] <flexcoders%40yahoogroups.com>,
>> "flexawesome" <[EMAIL PROTECTED]>
>> wrote:
>> >
>> > Hi there,
>> >
>> > do you know how can I use it to duplicate the image? It seems
>> doesn't
>> > work. any ideas?
>> >
>> > Thank you
>> >
>> > loader = new SWFLoader();
>> > loader.addEventListener(Event.COMPLETE, Bitmapdata)
>> >
>> > loader.source
>> = "http://us.i1.yimg.com/us.yimg.com/i/us/nt/ma/ma_tech-
>> > grp_1.gif"
>> > //addChild(loader);
>> >
>> >
>> > private function oBitmapdata(e:Event):void
>> > {
>> >
>> > var img:Image = new Image();
>> > var data:BitmapData = Bitmap(loader.content).bitmapData;
>> > var bitmap:Bitmap = new Bitmap(data);
>> >
>> > img.addChild(bitmap)
>> >
>> > addChild(img);
>> >
>> > }
>> >
>>
>>
>>
>
>