
244 Tutorial: Building Your First Flash Application
Add ActionScript code
You have now added all the graphic and text elements that your FMA
requires. The last step is to add the ActionScript code that displays the
proper text and image for each slide in the
slideShow
movie clip.
Test an ActionScript sample
First, you’ll add some simple ActionScript code to see it work.
To add the test ActionScript:
1.
In the Timeline, click the layer name actions to activate that layer.
2.
Select Window > Actions to open the Actions panel.
3.
In the Actions panel, type the following ActionScript code. You can
copy and paste the following code from the Flash Help panel:
function testFunc(eventObj:Object) {
menu_mc.title_txt.text = "Testing the title";
menu_mc.description_txt.text = "Testing the
description";
}
// add the event listener for the button
next_btn.addEventListener("click", testFunc);
This ActionScript code adds some text to the title and description text
boxes that you added to the
menu
movie clip earlier.
4.
Select Control > Test Movie.
The Flash document opens and plays in a new window.
5.
In the Test Movie window, click Next.
The test title and test description text you entered as part of the
ActionScript code appears in the blue rectangle on the right side of the
document.
6.
Save your document.
NO
TE
If you did not complete Chapter 7, “Tutorial: Handling Photographs” you
need get the images required for this tutorial. To do so, open the
cafe_townsend/completed_files/flash/images folder that you copied to
your hard disk in Chapter 4, “Tutorial: Setting Up Your Site and Project
Files,” and then copy the image0.jpg, image1.jpg, image2.jpg, and
image3.jpg files to the cafe_townsend/images folder.
TI
P
To add the text (in
quotes),
ActionScript refers
to the text boxes by
noting the name of
the
menu
movie clip
instance
that is on
the Stage
(menu_mc), and then
the name of the text
box itself within the
movie clip instance,
as follows:
menu_mc.description
This syntax is called
dot syntax
. It is used
throughout
ActionScript to refer
to objects that are
nested within other
objects.
000_ExploringStudio.book Page 244 Tuesday, August 30, 2005 9:30 AM
Summary of Contents for STUDIO 8-EXPLORING STUDIO 8
Page 1: ...Exploring Studio 8...
Page 8: ......
Page 42: ...42 Learning Studio...
Page 134: ...134 Web Development Workflow...
Page 136: ......
Page 162: ...162 Tutorial Creating Page Mock ups...
Page 182: ......
Page 194: ...194 Tutorial Handling Photographs...
Page 254: ...254 Tutorial Building Your First Flash Application...
Page 266: ...266 Tutorial Building a Video Player Flash Professional only...
Page 268: ......
Page 294: ...294 Tutorial Adding Content to Pages...
Page 324: ...324 Tutorial Formatting Your Page with CSS...
Page 332: ...332 Tutorial Publishing Your Site...
Page 342: ...342 Tutorial Setting Up Your Website for Contribute Users...
Page 350: ...350 Index...