Accessibility

ActionScript cookbook beta

Dynamically load and display an image

Problem Summary

You need to dynamically load and display an image.

Solution Summary

Use the Loader class to load the image.

Explanation

ActionScript 2

createEmptyMovieClip("loader", 10);

loader.loadMovie("image.png");

loader._x = 100;
loader._y = 100;
loader._rotation = 20;
loader._alpha = 50;

ActionScript 3

var request:URLRequest = new URLRequest("image.png");

var loader:Loader = new Loader();
loader.load(request);

loader.x = 100;
loader.y = 100;
loader.rotation = 20;
loader.alpha = .5;

addChild(loader);