Search tutorials
Object Creation
1)Open up your .fla once again. Click on the first frame on the main timeline and open up the actions window. 2)Type the following code for making an object for the class:-var myCircle:Circle = new Circle(circle_mc);3)The 'circle_mc' is the instance name of the MovieClip 'Circle', as told earlier, and myCircle is the name of the object of the class. 4)Now we need an enterFrame function with the Keypress condition check, which will execute the moveRight() method of the 'circle class. The whole code of the frame now looks like this:-
var myCircle:Circle = new Circle(circle_mc);
onEnterFrame = function()
{
if(Key.isDown(Key.RIGHT))
{
myCircle.goRight();
}
}
5)Save it. Ctrl+Enter to test the movie.
6)Press right to see if the circle moves to the right. It should I guess :), did'nt try it in flash, just writing from the top of my head.
7)Party!
I hope this example gives you a jump start to the world of classes in AS 2.0. | » Level Intermediate |
|
Added: 2005-10-12 Rating: 7 Votes: 9 |
| » Author |
| Iam a flash actionscript programmer. |
| » Download |
| Download the files used in this tutorial. |
| Download (0 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!