First time here? First time here? Newsletter Signup Newsletter
651326 Members and growing! | Flash Jobs
Search tutorials
Author: Aditya Sharma aka adit_ya_sharma | Website: http://www.ctoffakes.tk

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
(10 being the highest)
» Author
Iam a flash actionscript programmer.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

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

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: doc_chin7
» Description:

The flash's horizontal road drive was done in CS4 and was upgraded to CS6. The car responds to right/ left key and flash will auto-generate the movement of roads from left-right or right-left based on random number. Have fun driving in this virtual environment and avoid other cars... :) If you are creative, a road driving game can be created from it.

Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.