This site is now just an archive over the rise and fall of Flash. The domain is available for sale
Login | Register
Breadcrumbs: Dynamically Loading Images

Breadcrumbs: Dynamically Loading Images

This tutorial will show you how to dynamically load images from any URL. This article assumes basic knowledge of Flash MX.

One of Flash 5's major flaws is its inability to dynamically grab images. For Flash to become a true solution for building web sites it needs to provide the same level of extensibility and customization offered by HTML. Until now Flash developers using Flash for their webzines or shopping carts have found the lack of this minor feature to be a big issue.

With the release of Flash MX, Macromedia has answered. Flash MX uses the loadMovie method, typically for including external Flash files, to grab an image from any URL. In this tutorial, I'll explain the loadMovie method and develop a quick flash application that can dynamically show an image.

The loadMovie method can be called from any movie clip object including the root. This method takes two parameters URL and the optional variables parameter. The URL parameter provides a valid web address to any JPEG image and the optional variables parameter provides the HTTP method (GET or POST) for sending variable to the URL.

This content requires Flash Player 9 (or a more recent version). You need to upgrade your Flash Player

In the above example enter a valid image URL or use the existing URL to dynamically display an image. Before proceeding please download the example file here.

Loading our Image
To develop the test Flash application create a new Flash file. On the canvas place the static text 'Image URL:' and an input text box named 'xtImageURL'. Now build a button and place the button next to input box.

Next we need to create a blank movie clip to store our dynamic image. Build a new movie clip named 'mcImage'. Drag this blank movie clip beneath our 'Image URL:' text and set its instance name to 'mcImage'.

With the interface in place we need to implement our application to use the dynamic URL to place an image in the mcImage movie clip. To do this lts place the below action script on our button:


on( press )
 mcImage.loadMovie( txtImageURL.text );

This will dynamically load the image at the URL specified above and store it in the mcImage movie clip at x and y coordinates 0 and 0.

Flash still has a long way to go in its support for basic HTML and images but this is definitely a step in the right direction. In some of my Flash Remoting applications I've found the ability to dynamically grab images the perfect solution for dynamic incorporating logos or products creating a truly dynamic application. Now I can build a Flash template for how the data should be displayed and avoid making tedious edits to the Flash document for every tiny change.

More articles by Jason Michael Perry are available at his web site If you questions or comments you can also e-mail him at


About Jason Michael Perry

Jason Michael Perry is a freelance instructor, developer, and writer. Please check out his new book Breadcrumbs: ActionScript 3 by Smart Ameba Publishing. If you have questions, a topic you would like covered, or more feel free to email him at

Get new stories first

Click to follow us on Twitter!



No comments for this page.

Submit a comment

Only registered members can comment. Click here to login or here to register