Add MovieClip with ActionScript
Actions
We need to create a new instance of the ball we can refer to later. Open up the ActionScript window and add the following statement:
A quick breakdown of what that code is doing:
- var initiates a variable, or object
- ball1 is the variable or instance name. We will use ball1 to refer to our object in the future
- :ball declares the type of object we are creating.
- new ball(); refers to the Object Class we created in MovieClip Properties: ball
Now that we have an object to refer to (ball1) we can add it to the Stage with the following statement:
Test your work with CTRL+ENTER. An instance of ball_mc called ball1 should be in the top left corner of the Stage:
Since we haven't defined x,y coordinates for ball1 yet, Flash defaults to (0,0):