I'm displaying an external image in Flash with the loader object, and then addchild() and that whole thing. Im wondering how, if possible, I could then add that same child to another movie clip. So far, when i do, it doesn't show up in the original movie clip anymore. Is there a way for me to display an image twice by pulling it from the same source like you would do with html,css?
Do i have to use the bitmapdata object for something like this? Im reading about it and I cant even see the purpose for it.
Thanks guys!
Do i have to use the bitmapdata object for something like this? Im reading about it and I cant even see the purpose for it.
Yes, that's the way to go. Basically create a new Bitmap
that uses the same BitmapData
. Here's an example:
var loader:Loader = new Loader();
load.contentLoaderInfo.addEventListener(Event.COMPLETE, function(event:Event):void {
var bitmapData:BitmapData = event.target.content.bitmapData;
// Now to make as many Bitmap instances as we want
var bitmap1:Bitmap = new Bitmap(bitmapData);
var bitmap2:Bitmap = new Bitmap(bitmapData);
var bitmap3:Bitmap = new Bitmap(bitmapData);
// Use them for whatever you want here.
// Cleanup
event.currentTarget.removeEventListener(event.type, arguments.callee);
});
loader.load(new URLRequest('bitmap.png'));