MACROMEDIA FLASH 8-FLASH Specifications Page 231

  • Download
  • Add to my manuals
  • Print
  • Page
    / 290
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 230
Write a function for a button 231
Write a function for a button
A command in ActionScript is called a function. A function is a script that
you can write once and use repeatedly in a document to perform a certain
task. Youre going to write a function that makes the screen_mc movie clip
appear (
visible = true) when the user releases the mouse button.
1. In the Script pane of the Actions panel, click after the last line of code,
press Enter (Windows) or Return (Macintosh) twice, and type
//
function to show animation
2.
Press Enter or Return and click Insert Target Path, along the top of the
Actions panel. Select onButton_btn from the hierarchical tree, and
click OK.
3. In the Script pane, type a period (.) and double-click onRelease from
the list of code hints that appears.
4. In the Script pane, press the Spacebar and type the following:
= 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.
5. Press Enter or Return, and type the following:
screen_mc._visible = true;
6.
Press Enter or Return and type }; to specify the end of the statement.
The function should appear as follows:
// function to show animation
this.onButton_btn.onRelease = function(){
screen_mc._visible = true;
};
Page view 230
1 2 ... 226 227 228 229 230 231 232 233 234 235 236 ... 289 290

Comments to this Manuals

No comments