Hi everyone,

Say I have a MovieClip that has nested MovieClips for example

person_mc
   > body_mc
               > toe_mc
                        > toe_nail_mc
   > leg_mc
   > hand_mc

Then, I want to export this person_mc and use AS3 to move the body parts _mc around. How do I reference the body parts? Ideally, I am thinking there might be such thing as:

public class ToeNail {}
public class Toe {
   public var toeNail:ToeNail;
}
// ... and Leg and Hand class
public class Body {
   public var toe:Toe;
}
public class Person {
   public var body:Body;
   public var leg:Leg;
   public var hand:Hand;
}

is there such a thing? otherwise how to reference?

furthermore, what happens if the nested _mc is on some frames and not on some other frames?

Hi everyone,

Say I have a MovieClip that has nested MovieClips for example

person_mc
   > body_mc
               > toe_mc
                        > toe_nail_mc
   > leg_mc
   > hand_mc

Then, I want to export this person_mc and use AS3 to move the body parts _mc around. How do I reference the body parts? Ideally, I am thinking there might be such thing as:

public class ToeNail {}
public class Toe {
   public var toeNail:ToeNail;
}
// ... and Leg and Hand class
public class Body {
   public var toe:Toe;
}
public class Person {
   public var body:Body;
   public var leg:Leg;
   public var hand:Hand;
}

is there such a thing? otherwise how to reference?

furthermore, what happens if the nested _mc is on some frames and not on some other frames?

I'm not sure if it's the same in CS3/CS4, but in flash 8, with nested clips on the timeline you used that nasty _parent.{movieclipname}.{sub-movieclip name}.gotoAndPlay("waveArm") stuff to access the items that are on different levels of the stage....yuk, nasty!
If that's still available, then it's a quick and dirty option....

But you can do it without the timeline..Simply create classes for each of your body parts and derive them from Sprite (i.e. public class arm extends Sprite) and then create your person class, including instances of the body parts in your person class (also derived from Sprite).

You probably know this already but the Sprite class is basically a movieclip without a timeline..For animation, you add and remove eventlisteners and handlers for the ENTER_FRAME event and add code to handle moving/redrawing your object.

The body parts you want to be moveable should have some kind of public interface to allow the person object to move them around (public function move()???). These functions can then call animation code in that body parts class.

Likewise, your person object should have several move functions, (moveArm, moveLeg etc. etc.) which will call the corresponding body parts move function.
Don't forget to include/pass any parameters that you might need to use!

If you've done your graphics in the IDE, I'm not sure how you'd attach them to your class...Never done anything like that from the flash IDE.....Not in AS3 anyway! Most of the gfx for AS3 classes I've messed with are either drawn at runtime using the standard drawing API or are svg's or png's which end up embedded in the swf in the class code (using Flashdevelop!)


Jas.

Why is everyone using flashdevelop =(

but drawing in runtime can be very tedious at times. a simple SimpleButton takes so many other classes to create. So I wanted to use the IDE to draw stuff then put on stage.

I also have a habit of using frames to store a collection of enumerated graphics. not sure whether this is sound practice. but its really convenient. Say I have a symbol named Building. then on each frame I can draw a different building. Just by using gotoAndStop() i can quickly place different buildings across the screen. Say if the building gets an upgrade, then i can just gotoNextFrame() sort of thing.

Still... Ihave not found a solution to this problem. really annoying.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.