Copy And Modify A Button Function - MACROMEDIA FLASH MX 2004-LEARNING FLASH Manual

Learning flash
Table of Contents

Advertisement

In the Script pane, press the Spacebar and type the following:
4.
= function(){
The line of code that you just completed should appear as follows:
this.onButton_btn.onRelease = function(){
You already know how to select objects in the Insert Target Path dialog box; you'll now enter
the instance names directly into the Script pane.
Press Enter or Return and type the following:
5.
screen_mc._visible = true;
Press Enter or Return and type
6.
The function should appear as follows:
//function to show animation
this.onButton_btn.onRelease = function(){
screen_mc._visible = true;
};

Copy and modify a button function

You just created one function that sets the
user releases the mouse button after a button click. You can probably guess how to create another
function that hides the screen_mc movie clip: by setting the movie clip
when the user clicks an Off button. You'll create that function now.
false
In the Script pane, select the entire function that you just typed, including the comment, curly
1.
brackets, and semicolon. Copy the text as you normally would, using Control+C (Windows) or
Command+C (Macintosh).
In the Script pane, place the insertion point after the last line of code. Then press Enter or
2.
Return twice, and paste the text as you normally would, using Control+V (Windows) or
Command+V (Macintosh).
In the copied function, change the text in onButton_btn to read
3.
Remember, earlier you assigned an instance name of offButton_btn to an instance.
In the copied function, change the
4.
to
.
false
In the copied function, change the commented text after the slashes to read
5.
hide animation
Your entire script should appear as follows:
//Initialize document to hide screen movie clip.
this.screen_mc._visible = false;
//function to show animation
this.onButton_btn.onRelease = function(){
screen_mc._visible = true;
};
32
Chapter 3: Write Scripts with ActionScript
to specify the end of the statement.
};
visible
.
property of a movie clip to
visible
property of the screen_mc movie clip from
when the
true
property to
_visible
.
offButton_btn
function to
true

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

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents