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:

  1. var initiates a variable, or object
  2. ball1 is the variable or instance name. We will use ball1 to refer to our object in the future
  3. :ball declares the type of object we are creating.
  4. 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:

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Since we haven't defined x,y coordinates for ball1 yet, Flash defaults to (0,0):