How to access child movie clip of movie clip (deep level >=2)

Hello my idea for game is to use tilesheets for environment and movie clips for characters, so i create a character template for 4 directional moving, so i have four base movie clips (Up, Down, Left, Right). Each one contains movie clips (like Head, Body, Upper Leg, Left Hand), on this level some of this contains FillSkin (or other Fill like FillLeftEye) which is shared among others movie clips in this swf, So basically i want to load right movie clips for direction which is successful, and then enable right Eye Set for characters (e.g. Eyes 1, Eyes 2 which isn’t checked visible in flash when exporting swf) depends on user choice, also for further customization i want to access lowest level child FillSkin and change color of fill to user defined.

I read topic from April Extending MovieClips from an SWC with the SWF lib but the method showed here by accessing through child name isn’t working since importing or loading movie clip i get a name in format Movie Clip XXXX, i tried to preload swf, and while i use FemaleRight() it’s create me and instance of object type Female Right but all child objects have a type MovieClip with name Movie Clip XXXX.

So my question is there any way to get child movie clip by name/type (e.g. I want get symbols named in flash as _Right_Body)??

I presume you use the SWF library?

If you name it in Flash Professional, it should be named in the exported code.

In recent versions of OpenFL, you can even use dynamic access if you want:

var body = Character.RightBody;

The first level of an “Export for ActionScript” object should be typed as TextField, MovieClip, SimpleButton, etc. The next level down is typed as DisplayObject, so you may need to cast if you go down a lot of levels :slight_smile:

Hmm it seems i misunderstood, i thought calling by name was to get by symbol class name, not instance name, so while naming all parts of body by instance name resolved problem with class name showing as movie clip xxxx, i also slightly change my question is there a way to refer to symbol from library, instead of instance of symbol, to be truthful i don’t know if i think right but if it’s similar to other languages, the changing color of FillSkin fill will not change color in all instance which use symbol FillSkin to draw base Color, since it’s pretty late for me i don’t have time to actually check this so i ask about this instead.

In ActionScript 3, you check the is for each child object, to know if it is of that type. At the moment, the SWF library does not instantiate child objects (which are “Export as ActionScript”) using the same class instance name – they are more generic MovieClip or SimpleButton instances, so Std.is (clip, MyCustomClassType) won’t work in this case :smile:

Is it possible to use instance names? Otherwise, perhaps there is a certain layer order, like the clip that is the first child versus the second child always follows a pattern?

As for certain layer order it’s not something that will be the same for every character since i plan to add different clothes that characters can wear, how i do implement is yet to decided but my current idea is just add cloth layer in each body part so if for one part of body we can have different amount of clothes.

As for type of symbol, i know that they are more generic types like MovieClip or Shape, i saw this when tried to access child object (my idea was to check class type, and by this find the desired by us movie clip). Currently i would access probably by using instance name, also there is one question i want to ask is there possibly to make extension to base class in different file than the main body of class is present, I ask since some of programing languages allows for extension of class in different body and in case of conflicting names of methods or variables it use the last one, what i want for is to to add method to movieclip which return all childs with the same name, by childs i mean all shapes, movieclips on different deep level.

Sure, you can extend classes, even SWF classes that are exported. Sometimes I use a little script to create a new instance of these “smarter” types, then replace the simpler type in place, so at the same place, position, scale, so on, I have a replacement that has my additional functionality

If you extend i’m starting thinking about inheritance which is not what i ask, especially if you continue about creating new better intance of “smarter” class, what i think is it about inheritance, it’s minimum for modern programming language(at least for high level) so i even don’t need a confirmation at beginning when i was thinking if try to use this platform, what i ask is if i add in additional file with something like that:

class MovieClip{
function GetChildrensByName(name:String): Array
}

I can use this method in all instance of MovieClip, or i need to modify base MovieClip class to be able to use it?

You can get a child by name, at one level, like this (obviously):

clip.getChildByName (name);

However, you can augment existing types a couple ways in Haxe. One is “static extensions”

Another is “abstract classes”

Let me know if you have questions :slight_smile: