- Downloading the Example Files
- Creating your First Code Snippet
- Setting a Custom Cursor
- Setting a Source Video File
- Loading and Displaying an External Text File
- Loading and Displaying an External Image
- Linking to a URL
- Next Steps
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.
- On the Flash stage, select the page2_mc movie clip.
- 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).
- Test the movie.
- Click the third tab, and notice that a JPEG file has loaded into the .swf file in the upper-left corner (see Figure 6).
- Close the codesnippets_start.swf file to leave the Flash testing environment and return to the authoring environment.
- In the Actions panel, locate the line that reads:
- Place the cursor at the end of this line, and press the Return key to insert a new line.
- On the new line, insert the following code:
- Press Return once more, and on the next line type the following code:
- 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).
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.
addChild(fl_Loader_4);
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.
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.