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: S.Saipriya
» Title: Flash Fire Effect
» Description: This tutorial explains about how to create Fire Effect in Flash of Actionscript 2.0.I hope this tutorial helps you!
Featured Sound Loops
Image for equalize

Audio Player

» Author: Aidan Crouzet-Pascal
» Title: Falling Star
» Description: This loop is a cool sounding, E minor loop.
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: Brandan Paulin
» Description: Epic sounding loop with Brass, Percussion, Strings and Winds. This is actually part of a Loop Pack called the Coming where you can download the rest of the loops that go with it FREE from my website.