Reusing image from loader - how to duplicate image into a sprite


hello.

i'd able load external image , use loaded image multiple times within sprite.

so, can make out, need image out of loader somehow , use bitmap.

have been looking solution hours now, , attempting every possible permutation think of, have hit real dead end.

am hoping can point me in right direction.

 

here's code:

 

[code]

import flash.display.bitmap;

var sp:sprite = new sprite();

addchild(sp);

var bitmapdata:bitmapdata;

var imageurlrequest:urlrequest = new urlrequest("images/myimage.png");

var loader:loader = new loader();

loader.load(imageurlrequest);

 

loader.contentloaderinfo.addeventlistener(event.complete, imageloaded);

 

function imageloaded(e:event):void {

   bitmapdata = e.target.content.bitmapdata;

   var mybitmap:bitmap = new bitmap;

   mybitmap.bitmapdata = bitmapdata;

   (var i:int=1; i<3; i++) {

mybitmap.x = 300* (i-1);

sp.addchild(mybitmap);

}

}

 

[/code]

 

any ideas how can fix loaded image outputs 3 times in sprite?

many thanks.


use:

 

 

 

[code]

import flash.display.bitmap;

var sp:sprite = new sprite();

addchild(sp);

var bitmapdata:bitmapdata;

var imageurlrequest:urlrequest = new urlrequest("images/myimage.png");

var loader:loader = new loader();

loader.load(imageurlrequest);

 

loader.contentloaderinfo.addeventlistener(event.complete, imageloaded);

 

function imageloaded(e:event):void {

   bitmapdata = e.target.content.bitmapdata;


   (var i:int=1; i<3; i++) {

   var mybitmap:bitmap = new bitmap();

   mybitmap.bitmapdata = bitmapdata;

mybitmap.x = 300* (i-1);

sp.addchild(mybitmap);

}

}

 

[/code]

 




More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

Joomal 3.6.3 update error - PHP temporary folder is not set - Joomla! Forum - community, help and support

Upgrade 3.4.8 to 3.5.1 failed "download package failed" - Joomla! Forum - community, help and support

Fatal error during instalation - Joomla! Forum - community, help and support