Groups | Blog | Home
all groups > flash actionscript > april 2004 >

flash actionscript : Accessing a MC inside another MC?


dCsAitek
4/21/2004 11:50:46 PM
Hello... I have a MovieClip animating on the main stage and I need to tell
another MC inside of it to gotoAndPlay(2); ... however this code doesnt do the
trick:

firstMC.secondMC.gotoAndPlay(2);

How can I control that second MC?
ol_yello
4/22/2004 12:13:55 AM
That code should work, but you can't use the symbol names from the library. You
have to give the MC's instance names, then refer to those. So if your symbol
names are "firstMC" and "secondMC", you could make the instance names "first"
and "second" and the code would be "first.second.gotoAndPlay(2);"
dCsAitek
4/22/2004 12:18:21 AM
I know... They both have instance names... This is so simple, but it's not
working... I have no idea what's going on... is there something i dont know?

This is the layout:

Maintimeline.movie1.movie2.gotoAndPlay(2);

I another words... _root.movie1.movie2.gotoAndPlay(2); should work too...

Any ideas?
mandingo
4/22/2004 12:18:52 AM
Actually, if the second movieClip is inside firstMC then all you need is

secondMC.gotoAndPlay(2);

it is relative to the firstMC

ol_yello
4/22/2004 12:25:52 AM
Peter Blumenthal
4/22/2004 9:12:07 AM
[quoted text, click to view]

No, that's wrong. If you are targetting the 2nd mc from the main timeline,
the 1st MUST be included in the scope. Your example would only work if it
was in a handler attached to mc1.

2 things i would try.
1. trace the clip to make sure it is viable:
trace ("targetting: "+mc1.mc2);

If you get undefined, either your scope is wrong or the clip does not exist.
If it all appears fine, it might be worth putting a frame label on frame 2
of mc2, and trying that:

mc1.mc2.gotoAndPlay("myFrameLabel");


HTH
}`P
--
---------------------------------------
http://www.phageinteractive.com
PhageInteractive Ltd.
remove mm_ to mail
---------------------------------------
'If I come across as a grumpy and twisted old man, it's just because I'm a
grumpy, twisted, old man." - me
---------------------------------------

AddThis Social Bookmark Button