Search Tutorials
Tying it Together Still in the movie clip timeline, create a blank keyframe on the first frame of the actions layer. Open the Frame Properties dialog box and click on the Actions tab. Enter in the following code:Set Variable: "numblink" = /:numblink Set Variable: "x"="1" The first line of this code simply creates a link from the textbox that we named "numblink" in the main movie timeline to the variable named "numblink" that is local(only available) to the movie clip. If you have used the Tell Target action in you flash development, you will know that the "/" in the first line references the main timeline, while the ":" indicates that the information being retrieved is a variable (in this case "numblink" - the name of the textbox). The second line creates the variable named "x" and sets the value to one. (This variable x will be used as a counter in the comparison that will be carried out later in the clip. Now that we have initialized the variables, we need to compare them in order to determine how many times the clip will run. (Each run through of the clip will create one blink). Go back to the clip timeline and create a blank keyframe at frame number two. Again enter the frame properties box and click the actions tab. Enter the following code: If (x <= numblink) Set Variable: "x" = x+1 Else Stop End If I mentioned earlier that the "x" variable would be used as a counter. The first line simply compares our counter against whatever number the user entered. The second line indicates what happens if the above statement returns true. In this case, "x" will be increased by one so that when loop iterates again, the value of "x" will be one digit greater. This ensures that the loop has a finite ending. Therefore, when the value of x equals "numblink", the stop action is invoked and the blinking is halted. Lastly, we need to set up the loop so that the "If" statement can iterate until the terms for stopping have been reached. This is achieved through a "Go to and Play" action situated on the last frame on the Action layer. Just remember to specify that the place to start is frame two (which we labeled "start"). This is because if we were to let the clip play frameone again, the variables would be re-initialized and the loop would never end. Lastly, we have to set the button to call the blinker movie clip when it is clicked. This is done by assigning an instance name of "blink" to movie clip and adding the following code to the instance of the button.
On (Release)
Begin Tell Target("/blink")
Go To and Play(1)
End Tell Target
End On
That's about it. I hope this has provided you with an interesting exposure to some simple actionscripting. Best of luck and happy flashing!!
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|