Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Specifying changes in nested MCs

Status
Not open for further replies.
May 22, 2002
63
GB
Hi,

Can anyone help me with this problem:

I have an MC called 'one' nested within another MC called 'Nav' on the main timeline.

How do i tell flash to make alterations to the 'one' MC using the tellTarget command?

I've tried something like this: tellTarget (_root.Nav.one); gotoAndStop (1) - but it won't work.

Many thanks for any help,

Anders
 
Although it will still work, the tellTarget action is deprecated. Simply use the dot syntax:

_root.Nav.one.gotoAndStop(1);

Make sure Nav and one are the instance names of your movie clips, and not just their library names.

If you insist in using tellTarget it should be something like this:

tellTarget("_root.Nav.one"){
gotoAndStop(1);
} Regards,

new.gif
 
Sorry, I realised that the MCs I re-imported lost their names in the MC naming box.

Another question has arisen though: are targets used in the tellTarget command supposed to be in " " quotes? The ones I am using with nested levels seem to need them while those such as _root.nav don't need them to work?

Thanks for any help,

Anders
 
Could you tell me which command I should use instead of the tellTarget one if its use frowned upon?
 
There isn't a specific command, just something like...

_root.myClip.myVariable=myValue;

...for absolute paths or...

_parent.myClip.myVariable=myValue;

for relative paths.

Slainte

 
Hehehe...
Sure you're in the right thread Wang?
Looks like you got your Javas mixed up this time! ;-) Regards,

new.gif
 
OK, now I'm really stuck. I trimmed my (very poor but beginners coding to remove the tellTarget coding. It now looks like this and no longer works?

on (release) {
_root.Main1.gotoAndPlay(2);
_root.HomeSeq.gotoAndStop (1);
_root.Tab2.gotoAndStop (1);
_root.Tab3.gotoAndStop (1);
_root.Tab4.gotoAndStop (1);
_root.Nav.One.gotoAndPlay (2);
nav = "1";
_root.ClearSeq.gotoAndPlay (2);
_root.Nav.Two.gotoAndStop (1);
_root.Nav.Three.gotoAndStop (1);
_root.Nav.Four.gotoAndStop (1);
}
on (release) {
if (nav == "1") {
_root.Main1.gotoAndPlay (2);
_root.Main2.gotoAndStop (1);
_root.Main3.gotoAndStop (1);
_root.Main4.gotoAndStop (1);
}
}
on (release) {
_root.Tab1.gotoAndPlay (2);
}
on (release) {
If(bg == "1");
_root.gotoAndStop (2);
}
on (rollOver) {
_root.Nav.navID.gotoAndStop (2);
}
on (rollOut) {
if (nav == "0") {
_root.Nav.navID.gotoAndStop (1);
}
}
on (rollOut) {
if (nav == "1") {
_root.Nav.navID.gotoAndStop (2);
}
}
on (rollOut) {
if (nav == "2") {
_root.Nav.navID.gotoAndStop (3);
}
}
on (rollOut) {
if (nav == "3") {
_root.Nav.navID.gotoAndStop (4);
}
}
on (rollOut) {
if (nav == "4") {
_root.Nav.navID.gotoAndStop (5);
}
}

Apart from the messy nature of the code, it worked with the tellTarget commands, but now does nothing?

Help!
 
Ok! Now you're confusing me!

Hope you kept your original file and corrected a copy of it, so that you could revert to your original file if you had problems. Although if it was working, as you're now saying, why were trying to fix it?

What are all these actions? All different buttons?
Rather than troubleshooting 60 different items can we start by getting one button working, and then go from there?

If you could post your .fla, it might be easier to help you out, but if you can't, can we start with your first script and only that one...

on (release) {
_root.Main1.gotoAndPlay(2);
_root.HomeSeq.gotoAndStop (1);
_root.Tab2.gotoAndStop (1);
_root.Tab3.gotoAndStop (1);
_root.Tab4.gotoAndStop (1);
_root.Nav.One.gotoAndPlay (2);
nav = "1";
_root.ClearSeq.gotoAndPlay (2);
_root.Nav.Two.gotoAndStop (1);
_root.Nav.Three.gotoAndStop (1);
_root.Nav.Four.gotoAndStop (1);
}

First off, are all Main1, HomeSeq, Tab2, Tab3, Tab4, Nav, One, ClearSeq, Two, Three, Four, movie clips with those exactly spelled instance names?
Do you get "target not found" errors?
All of these actions should happen on the same button release?

Can you post just this exact same script (only for this button) when you were using tellTarget?

But once again a .fla would be worth a thousand words! Regards,

new.gif
 
Sorry about all this I'm totally new to Flash...

OK, since my post I've solved some of the problems:

all the MCs are named correctly - i'm certain (case and all.)

Here is the important bit of the code now, it sits on a button in the _root.Nav. level, and when its pressed makes 2 MCs on the _root level play, and is SUPPOSED to make an MC in the _root.Nav. level play called one. I am calling this like so:

_root.Nav.one.gotoAndPlay (2);

But it will not play.

Here is the code that matters:

on (release) {
nav = "1";
_root.HomeSeq.gotoAndStop(1);
_root.Tab2.gotoAndStop(1);
_root.Tab3.gotoAndStop(1);
_root.Tab4.gotoAndStop(1);
_root.ClearSeq.gotoAndPlay(2);
_root.Nav.one.gotoAndPlay(2);
_root.Nav.two.gotoAndStop(1);
_root.Nav.three.gotoAndStop(1);
_root.Nav.four.gotoAndStop(1);
if (nav == "1") {
_root.Main1.gotoAndPlay(2);
_root.Main2.gotoAndStop(1);
_root.Main3.gotoAndStop(1);
_root.Main4.gotoAndStop(1);
}

What happens at the moment is that everything residing on the _root. level plays fine. BUT the _root.Nav.one, _root.Nav.two, _root.Nav.three etc. sub-levels will not play?

So, all the lines work except these:

_root.Nav.one.gotoAndPlay(2);
_root.Nav.two.gotoAndStop(1);
_root.Nav.three.gotoAndStop(1);
_root.Nav.four.gotoAndStop(1);

I can send you an fla if you give me your email?
Will the gotoAndPlay commands above only work if preceded by an 'if' statement perhaps like the ones that work? I'm totally stuck!

Thank you for your help
 
It's better to keep the names of your clips and variables distinct if only from a debugging point of view.

Here's a slightly more well-formed piece of code for the second half which works for Flash 5/MX although it would be even better as a switch statement (MX only).

on (rollOut) {
if (nav == "0") {
_root.Nav.navID.gotoAndStop (1);
}
else if (nav == "1") {
_root.Nav.navID.gotoAndStop (2);
}
else if (nav == "2") {
_root.Nav.navID.gotoAndStop (3);
}
else if (nav == "3") {
_root.Nav.navID.gotoAndStop (4);
}
else if (nav == "4") {
_root.Nav.navID.gotoAndStop (5);
}
}

Or you could simply do this:

_root.Nav.navID.gotoAndStop(nav+1); Slainte

 
Before sending me your file (oldnewbie@hotmail.com), try doing this...

In the first frame of your one, two, three, four movie clips, put this action:

trace(this);

This will output the correct paths to those movie clips in the output window. If they're similar (_level0 would be the same as _root if that's the only difference!) to what you already have in your "not working" actions above, send me your file. If not try correcting your paths as outputed in the output window. Regards,

new.gif
 
Weird,

If i change _root.Nav.one.gotoAndPlay(2);

to this:

tellTarget("_root.Nav.one"){
gotoAndPlay(2);}

it works!?!?
 
Yes weird!
Have you tried the trace thingy?

Other than that, try changing the instance name of one to something like test1 and using:

_root.Nav.test1.gotoAndPlay(2); Regards,

new.gif
 
Hiya,

I tried the trace and everything checked out... very strange. Converting back to tellTarget makes it all work again????

I have found that flash doesn't like talking to MCs more than one level away from the button containing the actions you want executed on it.

A bug perhaps?

As you suggest it could be similarities in variable/MC names, but I can't believe it is THAT sensitive. Weird...
 
Are all those unresponding movies present on the same frame as the button? If not that could be the source of the problem, because usually you can easily control in far more nested levels than your are. Maybe dot syntax is more sensitive to that "presence" than tellTarget would be. Regards,

new.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top