Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Adobe Creative Suite

  • Print
  • + Share This
Like this article? We recommend Loading and Displaying an External Image

Loading and Displaying an External Image

As you have seen, ActionScript can be used to load many types of content at runtime, and code snippets make it easy to load the commonly used types. You will now add a snippet to load an external JPEG file.

  1. On the Flash stage, select the page2_mc movie clip.
  2. With the clip selected, go to the Code Snippets panel and double-click the snippet called “Click to Load/Unload SWF or Image,” which is located in the Load and Unload folder (see Figure 5).
  3. Test the movie.
  4. Click the third tab, and notice that a JPEG file has loaded into the .swf file in the upper-left corner (see Figure 6).
  5. This image would look much better if it were center on the page and not obstructing the view of the interface, so you will modify the ActionScript to adjust the image’s position.

  6. Close the codesnippets_start.swf file to leave the Flash testing environment and return to the authoring environment.
  7. In the Actions panel, locate the line that reads:
  8. addChild(fl_Loader_4);
  9. Place the cursor at the end of this line, and press the Return key to insert a new line.
  10. On the new line, insert the following code:
  11. fl_Loader_4.x = 70;

    The x property determines the horizontal position of an object. The code you just added will place the image 70 pixels from the left side.

  12. Press Return once more, and on the next line type the following code:
  13. fl_Loader_4.y = 70;

    The y property determines the vertical position of an object. The code you just added will place the image 70 pixels from the top.

  14. Once more, test the movie, and click the third tab. Notice that the JPEG file is in the new location that you set with ActionScript (see Figure 7).
  • + Share This
  • 🔖 Save To Your Account