Be a Supporter!

About Actionscript classes?

  • 222 Views
  • 2 Replies
New Topic Respond to this Topic
qwereeer
qwereeer
  • Member since: Jun. 29, 2007
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
About Actionscript classes? 2011-01-07 20:59:15 Reply

Hey. I am new to Actionscript 3.
I want to know the basics of actionscript 3 programming using classes.
I'd appriciate very much if you answer me. Thnx

1. When I link a class to movieClip, does the code inside that class work only when movieclip is
on the stage?

2. Where is _root? If I want to change values of the root timeline's variable, how to do that?
(I mean, I want to do that by putting code in a class, not on the root timeline)

3. I know that a class can be linked to only one movieClip. What do I do when I want multiple movie-
clips to be linked to a same class?
(For instance, I want to make two different enemies who act as same as each other
because their class is same)

I am not a native speaker, so I may have some grammar mistakes.
I'm sorry if I make you hard to read, but please tell me.


w

zrb
zrb
  • Member since: Aug. 8, 2006
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to About Actionscript classes? 2011-01-07 21:04:40 Reply

At 1/7/11 08:59 PM, qwereeer wrote: 1. When I link a class to movieClip, does the code inside that class work only when movieclip is
on the stage?

It doesn't need to be on the stage to work.

2. Where is _root? If I want to change values of the root timeline's variable, how to do that?
(I mean, I want to do that by putting code in a class, not on the root timeline)

Root is root, you have access to it from any display object.
If you want to do stuff to root, then you cast it as MovieClip, like MovieClip(root).nextFrame().

3. I know that a class can be linked to only one movieClip. What do I do when I want multiple movie-
clips to be linked to a same class?

You make a class that extends MovieClip and then in your library, you set the 2 movie clips to the same class you created.


School Sux ! || As :Main || As3: Main || Animation: Main || Flash Tutorials ||

BBS Signature
23450
23450
  • Member since: May. 28, 2003
  • Offline.
Forum Stats
Supporter
Level 27
Blank Slate
Response to About Actionscript classes? 2011-01-08 12:13:22 Reply

At 1/7/11 09:04 PM, zrb wrote: You make a class that extends MovieClip and then in your library, you set the 2 movie clips to the same class you created.

Just wanted to add that its the base class that you want to define.

So have an enemy that uses the class Tank, and a base class of Enemy. And then another enemy using the class Zombie, and a base class of Enemy. Then both of those enemies extend the same class.


BBS Signature