Add Actionscript Code - MACROMEDIA FLASH 8-GETTING STARTED WITH FLASH Getting Started

Table of Contents

Advertisement

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
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
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.
slideShow
movie clip earlier.
menu
movie clip.
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.

Add ActionScript code 125

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents