• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 9. Controlling Information Flow > Using Variables and Expressions

Using Variables and Expressions

Use variables and expressions as placeholders for parameters within your ActionScript. In virtually every action that requires you to enter a parameter, you can place a variable or an expression instead. For example, the basic action gotoAndStop gives you the option to enter an expression instead of a frame number in the Frame field. This expression might be a variable called myCard that holds a number between 1 and 52. Frames 1 through 52 on the Timeline could contain graphics of the 52 playing cards, so changing the variable myCard in the gotoAndStop action would make Flash display different cards. In the action getURL, the URL field can be an expression rather than the actual name of an Internet address. For example, the expression might be a string concatenated with a variable such as "http://"+yourWebSite. Changing the variable called yourWebSite makes Flash load different URLs with the getURL action. Values for the properties of objects and target paths for objects can be replaced with expressions in the setProperty action (Figure 9.8).

Figure 9.8. Examples of using variables and expressions in parameters fields of actions: The variable frameNumber in gotoAndPlay (top), the variables myURL and myWindowName in getURL (middle), and the variables MovieClipName and myRotation in setProperty (bottom).



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint