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

Hour 15. ActionScripting Applications fo... > Task: Create and Change a Custom Pro...

Task: Create and Change a Custom Property in a Movie Clip

In this task you're introduced to using variables that are unique to instances of a clip (that is, homemade properties). Here are the steps:

1.
Draw a circle and convert it to a symbol. Name the symbol “Ball” and make sure it's a Movie Clip.

2.
Use the Properties panel to name the instance of the Ball on the Stage to ball1 (remember it's this instance name we use to address this clip).

3.
Select the instance of ball1 and use the Actions panel to insert an onClipEvent (plus button, Actions, Movie Control). Check the enterFrame button. Then insert an evaluate Action (Actions, Miscellaneous Actions) and type: _x+=speed. Translated, the entire script says, on the enterFrame event (which occurs 12 times a second) increase the _x property by a value equal to speed. We just made up the variable called “speed” (now we have to keep track of it).

4.
To set the “speed” variable of the clip we use the same syntax as we would to set a built-in property of that clip. Create a button and attach an evaluate Action that reads ball1.speed=5. Test the movie. You could make another button that sets speed to -5 and the ball will move to the left. Or you could have two events on one button: on the press event set ball1.speed=5; on release set ball1.speed=0.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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