Basic Tutorial

This tutorial will teach you the basic steps involved in using the advancedLoader component to first load images from the library, then to load external JPG and SWF files.

1. Loading an image from the library

Having installed the component using the Macromedia Extension Manager open Flash and create a new file.

Open component panel ('Window' > 'Components') and drag a copy of the advancedLoader onto the stage.

Using the transform tool or the properties panel ('Window' > 'Properties') scale the component to your desired image size. In the properties panel give your component an instance name, for the purposes of this tutorial use 'al' (without the quotes).

Setting the component properties

Using the rectangle tool draw a shape on your stage to represent a button. Using the text tool add some text to identify your button, as this button will load an image from the library we have used the phrase "Load image from library". Select the shape and text and press the F8 key to convert them to a symbol. The 'Convert to Symbol' dialogue box will appear, give your button a name, select 'Button' as the symbol's type and click 'OK'.

Creating a button

Select the button on the stage and in the properties panel give the component an instance name, for the puposes of this tutorial use 'library_btn' (without the quotes).

Setting the button instance name

Open the 'Create New Symbol' dialogue box ('Insert' > 'New Symbol...'). Give your symbol a name and select 'Movie clip' as the symbol's type. Tick the 'Export for actionscript' checkbox, the 'Export in first frame' checkbox should become ticked as soon as you do so. Give the movie clip an identifier, for the purposes of this tutorial use 'library-image'. Click 'OK'.

Creating a movie clip with linkage

If you are not taken directly to the new movie clip's timeline, double click it in the library to enter it's timeline. On the stage import an image for the component to load by selecting 'File' > 'Import' > 'Import to Stage...', select an image to import and click 'Import'.

Return to your main timeline and create a new layer, name it 'script'.

Select the keyframe of your new layer and open the actions panel ('Window' > 'Actions'). In the actions panel enter the following script:

library_btn.onRelease = function()
{
  al.load("library-image");
}

Entering script in the actions panel

Save your file ('File' > 'Save') and test your movie ('Control' > 'Test Movie'), click your button to see your image load into the component.

2. Loading an external image

Using the rectangle tool, and the text tool create a second graphic on the stage, select the graphic elements and press F8 to convert them to a symbol.

With the symbol selected on the stage open the properties panel and give the button the instance name 'external_btn'.

Creating

Select the first keyframe of your 'script' layer and in the actions panel, immediately below the code you previously entered add the following script:

external_btn.onRelease = function()
{
  al.load("external-image.jpg");
}

This script is almost identical to the previous button's script except that it refers to an external image. The distinction is made by the use of the period in the load method's parameter: If a period is present in the string the component assumes the image is an external one, if there is no period the component will assume the parameter refers to the linkage ID of a movie clip in the library.

You should now prepare an image to load into Flash. This can be done in any image editing application that allows you to save a file as a non-progressive JPG. For the purposes of this tutorial save the image as 'external-image.jpg' in the same folder as your other files.

It is important to note that prior to Flash 8, the only image files Flash is capable of loading are non-progressive JPGs.

Save your file and test your movie. Click on your new button to see the component load your external image.

3. Loading an external SWF file

As well as loading external images the component is able to load external SWF files.

On your stage follow the same process as before to create a button on your stage, this time giving it the instance name 'swf_btn' in the properties panel.

Creating

You should now prepare a SWF file for the component to load. You should save the SWF file to the same folder as your other files. For the purposes of this tutorial name it 'image.swf'.

Select the first frame of your 'script' layer and beneath the previous code add the following:

swf_btn.onRelease = function()
{
  al.load("image.swf");
}

Save your file and test movie, you will be able to load your different files, the movie clip in your library, the external JPG file and the external SWF file by clicking on the different buttons.