STEP 13 building a conditional statement in the EXPRESSION EDITOR


Using a conditional statement is a way of checking whether something is true or false. Usually we check the value of a variable. We can check whether the value is greater than, less than, equal to, or some combination of these. If the statement is true, we do one set of routines. If it is not, we do another. Here I'll show you how to check what frame the playback head is on in the Dancer Clip (see figure 08:26).


Figure 08:26.

graphics/08fig26.jpg


The Expression Editor allows you to build an expression from a preset list of available functions, properties, and operators. It's kind of like a library of built-in routines. This is the heart of Actions script.

  1. Scroll down the Function list on the right until you find the _currentframe property and double-click it to insert it in the expression field. The _currentframe property is the current frame of the movie clip. This is used to keep track of where the playback head is in the movie clip.

  2. In the expression field, after _currentframe, enter > 10. You could also select the greater than symbol from the Operators list on the left. Click OK to exit the Expression Editor and return to the Actions panel.

  3. From the Add Action list, choose Go To and then select the Expression option and enter a variablefor this example, dancer_framelabel.

    This variable will be set by the various buttons calling the RolloverScript. The /dancer movie clip has a series of labels for different frames . Be sure to select the Go To and Play option.

    The If-End clause is now complete, but you need to add an Else clause to give an alternative set of instructions. If the Else clause is left out, the movie clip would never play initially (because the _currentframe at the start is less than 10).

  4. Make sure the "If" statement is selected; then click the Add Else/Else If Clause button.

    An Else action is added between the If and End If actions.

  5. Select the Else action and make sure that the Elseand not the Else Ifoption is selected.

  6. Add a Play action below the Else action.

    The complete code for the second section of the RolloverScript should look like this:

      Set Property ("/dancer", Alpha) = "66"   Begin Tell Target ("/dancer")   If (_currentframe > 10)   Go to and Play (dancer_framelabel)   Else   Play   End If   End Tell Target  


Flash Web Design The Art Of Motion Graphics
Flash Web Design oder: the art of motion graphics
ISBN: 3827256623
EAN: 2147483647
Year: 2005
Pages: 192

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net