DevlogsDevlogs
Is it possible to clone Loader instance to save some bandwidth?
Yes, this is possible.
Solution of this problem depends on type of loaded media. Lets take a look on how to clone loaded media.
If you've loaded image (png, jpg or gif) file, and you're not going to do any pixel level manipulation
var s:Bitmap = new Bitmap( (oldLoader.getChildAt(0) as Bitmap).bitmapData )
using this to create multiple bitmaps can also save used memory - only one BitmapData instance is created and shared across all bitmaps.
If you need to do any pixel level editing, its important to first clone BitmapData!
If you've loaded swf file. You can clone Loader and use its loadBytes public method to load already loaded data
newLoader.loadBytes( oldLoader.contentLoaderInfo.bytes )
lol...
both codes works fine... it looks like You need to practice more if You had any problems with them :)
Thanks! Very helpful code. Not only saves bandwidth, but much more elegant than loading multiple times :-)
12 months ago Tuan Minh #0
You must be really lazy..
How come you put codes on your site and never test if it can run or not.