Flash Script
none none none
none Summary
This code is broken down into 2 steps.
Load the bitmap and once the image has loaded, add it to the stage.
The code is presented at the end of this article


Load Bitmap
In the loadBitmap function we create a Loader object, and add the event listener to the loader object. We are listening in on the 'Complete' event. This would notify the imageLoaded() function once your image has completely loaded. To start this process we call the load() method.

Event Listener
The imageLoaded function gets called once the image has completely loaded. In this function we create a Sprite object and add the bitmap to it using the addChild method. We then add this sprite to the stage using the addChild() code.



Code
(Cut and paste the code below into your 'actions' window, Window -> Actions. To execute, Control -> Test Movie)




Alternative way to load the image,
Since the loader itself is a displayObject, you can add the display object to the stage. And we could skip the event complete altogether

i.e.
var loader:Loader = new Loader();
loader.load(new URLRequest(bitmapFile));
addChild(loader);

none
none none none







History Licensing & Pricing Privacy Policy Contact Us
Frequently Asked Questions