Why ActionScript?
This programming language is nice for beginner who want to learn the program logic fun. ActionScript is my first programming language and it is learn by myself. I think it is easy to handle the graphic and animation let's focus on the main program logic.
Step one - Create a new MovieClip
MovieClip is an object. It should be a simple graphic or an animation. In this tutorial we will draw a circle on the MovieClip and use program to add the MovieClip on the screen. Let's do it!
- Press Ctrl-F8 to create a new MovieClip
- Fill the name: "mc_ball"
- Click "Advanced"
- Click "Export for ActionScript"
- Click "OK" button
- Draw a circle
Step two - Put the MovieClip on the screen via programming
- Return to the main screen
- Select the first frame
- Press F9 to open "Actions" window
- Coding
var ball:MovieClip = new mc_ball();
stage.addChild(ball);
Step three - Let's view the result
Press Ctrl-Enter
Learn more about programming!
var ball:MovieClip = new mc_ball();
/*
Do you remember "mc_ball"? This is the name of MovieClip which we created at the step one.
"Export for ActionScript" is very important.
It cannot use this MovieClip in the programming if you skip this step.
The whole line means create a new MovieClip "mc_ball" and named it "ball" to use in the program.
*/
stage.addChild(ball);
/*
Put "ball" on the screen.
"stage" is a key word represent the root of the screen.
*/
Let the ball on the center of the screen.
var ball:MovieClip = new mc_ball();
ball.x = stage.stageWidth / 2;
ball.y = stage.stageHeight / 2;
stage.addChild(ball);
/*
We can control the "ball" and set x-axis, y-axis to change it's position.
"stage.stageWidth" means screen width.
"stage.stageHeight" means screen height.
*/
Maths
Center x-axis is equal to half of width of stage.
Center y-axis is equal to half of height of stage.
Thanks~
Top comments (0)