This content has been marked as final. Show 5 replies
well, i kept poking around and found a way to address the nested clips in a long chain. It just takes too many lines of code (at least 7) for something that before could be done in 1 line. So I'm not sure it this is the best approach.
In the class definition i created names for each of the clips (using the name property).
and then in my main flash movie: I coded this:
tempClip = sp1.getChildByName('sp2');
tempClip2 = tempClip.getChildByName('sp3');
Is there a better approach? Thanks.
MovieClip(sp1).MovieClip(sp2).MovieClip(sp3).x = 70;
Personal though, if you are creating your clips on the main timeline of your movie using var = new, it is so much easier to simply access the clip in question using it's variable name in AS3 rather than going through the messes of accessing nested clips.
Thanks for your suggestions. I tried the first one: using
got this error message:
TypeError: Error #1006: MovieClip is not a function.
If i try this instead:
MovieClip(sp1.sp2.sp3).x = 70;
the error I get is:
TypeError: Error #1010: A term is undefined and has no properties.
I am curious about your 2nd suggestion, but I'm not sure how to implement it. I wonder if you can expand more on it.
I am thinking on situations when you need to address a nested clip and have many copies of the parent clip already on stage. In this cases The instance names of all the parent clips will always be different, but the nested clip may all have the same instance name. So you need a way to specifically address the nested clip of one of many parent clips.
My second option refers to using variable declaration with the new operator. It's the method for creating empty movieclips and attaching them from the library from AS. Here's the code....
thanks so much.