R – AS3:Best practice for getting image from Loader()

actionscript-3apache-flexflash

When loading images using Loader, what's the preferred way to add the image to the display list? Grabbing the data in an Event.COMPLETE handler like new Bitmap( Bitmap(LoaderInfo(e.target).content).bitmapData ) , or adding the Loader instance itself?

Best Answer

If you only want to display the Loader's content, then feel free to add the Loader to the display list rather than extracting its contents. It's an uncommon situation when you'll need to reparent a Loader's content.

Additionally, it's worth noting that a Loader's content will not always be accessible. For instance, Flash Player places security restrictions on content loaded from other domains. When these stronger security rules are enforced, Flash Player throws security errors at runtime if you try to access the Loader's content.

Related Topic