Add Frame Labels For Navigation; Add Conditional Logic For The Submit Button - MACROMEDIA FLASH MX 2004-LEARNING FLASH Manual

Learning flash
Table of Contents

Advertisement

Add frame labels for navigation

When the viewer presses the Submit button, you want Flash to jump to either the error message
or the confirmation message, depending on what is entered in the text field. Labeling a frame
helps you easily reference it in ActionScript. This is helpful for sending the playhead to a
specific frame.
Next, you'll add frame labels to help you navigate your Flash application.
Add a keyframe (Insert > Timeline > Keyframe) to Frame 5 of the Actions layer.
1.
In the Property inspector, type error in the Frame Label text box. Press Enter or Return.
2.
The label text and a flag appear in Frame 5 of the Timeline.
Add a keyframe to Frame 10 of the Actions layer. In the Property inspector, type confirm in the
3.
Frame Label text box. Press Enter or Return.

Add conditional logic for the Submit button

With ActionScript, you can have Flash compare information and take action based on criteria you
specify. In this example, you'll add ActionScript for Flash to take one action if the user enters no
data in the text field, and a different action if the user does.
Select Frame 1 of the Actions layer. In the Script pane, place the insertion point after the
1.
code. Press Enter or Return.
stop();
Type the following comment:
2.
validates user input
In the Actions panel, click the Insert a Target Path button, located at the top of the panel.
3.
In the Insert Target Path dialog box, verify that Relative is selected. Click submit_btn on the
4.
hierarchical tree, and click OK.
In the Script pane, type a period (.) after
5.
With the insertion point after
6.
Place the insertion point between the curly braces and press Enter or Return, and then type
7.
(url_txt.text == null || url_txt.text == ""){
The parallel lines are equivalent to logical or in ActionScript.
With the insertion point still inside the curly braces, press Enter or Return.
8.
Type
9.
gotoAndStop("error");
Place the insertion point after the curly brace and type
10.
Return.
//Adds conditional logic for the Submit button that
. Press Enter or Return.
submit_btn
, type
onRelease
in the Script pane. Press Enter or Return.
, and then type
onRelease
in the Script pane.
= function (){}
in the Script pane.
in the Script pane. Press Enter or
else{
Add conditional logic for the Submit button
.
if
109

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-LEARNING FLASH and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents