Add ActionScript code 129
image0uri
contains a string that is the Universal Resource Identifier for
the image file that is loaded and displayed in each section of the
slides
movie clip.
The next two lines of code declare two more variables:
var currImage:Number = 0;
var totalImages:Number = 4;
The first variable,
currImage
, stores the number of the current image that
is being displayed in the
slides
movie clip. The second variable,
totalImages
, stores the total number of images that are available to be
displayed. By storing this last number in a variable, you make it easier to
change the number if you want to add more images to the slide show later.
You would also need to modify the
slideShow
movie clip in that case.
The next line of code sets the text of the title text box to the text in the
variable whose name corresponds to the current image number.
menu_mc.title_txt.text = this["image"+cu"title"];
This code uses dot syntax to set the text property of the title_txt text box in
the
menu_mc
movie clip instance to the value of a variable. In this case the
variable name is constructed from the word image plus the value of the
currImage
variable, plus the word
title
. The variable name becomes
image0title
or one of the other similar variable names, depending on the
number contained in the
currImage
variable. The word
this
indicates to
Flash that the variable was declared inside this same script.
The following line of code is similar to the previous one:
menu_mc.description_txt.text =
this["image"+cu"desc"];
This line of code sets the text of the description text box in the
menu_mc
movie clip instance to the text in the
desc
variable that corresponds to the
current image number.
The following lines of code set up a
for
loop to load external JPG image
files into the
holder
movie clip instances, which are in the
slides
movie
clip in the
slideShow
movie clip. The file paths to each external JPG file
are stored in the
image*uri
variables declared in the beginning of this
ActionScript code block, as follows:
for (var i:Number = 0; i<totalImages; i++) {
slideShow_mc.slides_mc["holder"+i].loadMovie(this["image"+(i
)+"uri"],slideShow_mc.slides_mc.getNextHighestDepth());
}
000_Getting_Started.book Page 129 Friday, September 2, 2005 12:22 PM
Summary of Contents for FLASH 8-GETTING STARTED WITH FLASH
Page 1: ...Getting Started with Flash...
Page 26: ...26 Introduction...
Page 94: ...94 Flash Basics...
Page 152: ...152 Index...