PDA

View Full Version : Accessing nested movieClips from the main timeline



fs_tigre
June 3rd, 2009, 09:45 AM
Hi,
Last night I was trying to access some nested movieClips from the main time line but it was giving an error.
What I have is a movieClip on the stage called “dog” and inside this movieClip I have two nested movieClips called “dogLH” and “dogRH”. The movieClip “dog” was brought to the stage using actionscript 3.0 and when I tried to move the moveClips inside “dog” it gave me an error.

This is the code I have:


var dogog = new Dog();
dog.x =200;
dog.y =150;
addChild(dog);


And at a later time I was trying to move the hands like this (these are going to be tweened) and is when the error came up.



dog.dogLH.x =150;
dog.dogLH.y =200;


What is strange is that if I add the movieClip “dog” to the stage manually and try the same thing it works. Any idea why it doesn’t work when it is brought to stage with actionscript, but it works if I bring this manually?
Thanks

cbeech
June 3rd, 2009, 10:02 AM
when you are making the calls to dog.dogLH - is this done within the same scope that you declared 'dog'?

secondly, i thinking that since you have not strict typed the instance as MovieClip (or Dog), that you may need to cast (if in the same scope) OR strict type the instance as in:


var dog:MovieClip = new Dog();

//OR

MovieClip(dog).dogLH.x = X;

fs_tigre
June 3rd, 2009, 08:11 PM
Thank you!