开发者

Reference a Dynamic Movieclip from an outside Movieclip

I have built a movieclip (parentMC) that houses two movieclips within it (mcA, mcB).

in mcA, i'm dynamically attaching movieclips from the library through a loop.

in mcB开发者_StackOverflow i'm trying to reference a particular movieclip from mcA via "_parent.mcA". Doesn't seem to be working. However, when i reference said movieclips from the loop within mcA - or even parentMC, it works fine.

is there a special path exception? i've tried using _root and even the _level paths and still no luck. All responses are appreciated!


One problem I can see is that your newMC clips are all being created at the same depth (10), so each will overwrite the last, leaving only newMC4 at the end...

Try this instead:

for(i=0; i<5; i++){
   var dynMC:MovieClip = this.attachMovie('libMC'+i, 'newMC'+i, this.getNextHighestDepth());    
}

Having done that, your _parent.mcA.newMC1._y = 25; line should work if everything is set up as you say, so something else might be wrong. Here are some things to try:

  1. Check that mcB's parent really is the same as mcA's, by adding trace("mcB = "+this); inside mcB, and trace("mcA = "+this); inside mcA.
  2. Check that your dynMC clips are being created correctly: add trace("dynMC = "+dynMC); on the next line after this.attachMovie....

Hope this throws some light on where the problem lies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜