• 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 or method that requires you to enter a parameter, you can place a variable or an expression instead of a fixed value. The basic action gotoAndStop, for example, 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 in 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 a static Internet address. 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.6).


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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