View Full Version : _parent not working
massive3215
November 7th, 2004, 04:57 PM
Hi, this is a newbie question so it's probably easy for most of you to answer.
I have a movie clip that has the following code:
on (release) {
_root.rightMenu_mc.gotoAndStop("Animation");
}
It works fine the way it is but I read that it is better to use relatives paths rather than _root all the time but when I change it to _parent.rightMenu_mc.gotoAndStop("Animation"); it doesn't work anymore. Can anyone explain and help me out with this? Thanks!
ghjr
November 7th, 2004, 05:02 PM
Where is the button located at? The main stage or inside some movieclip?
glkngs
November 7th, 2004, 05:06 PM
What you read about relative paths was right! Forget that you've ever heard of _root, hehe.
is the mc placed on the main timeline, and not nested inside a movieclip?
massive3215
November 7th, 2004, 05:19 PM
The movie clip that you click on is nested within a movieclip called emptyLeft_mc
glkngs
November 7th, 2004, 05:24 PM
well theres your problem:
to get back to your main timeline, you have to use _parent twice, the first time it will refer to mc "emptyLeft_mc", and then the second time it refers to main timeline.
so the script will look like this:
_parent._parent.rightMenu_mc.gotoAndStop("Animation");
massive3215
November 7th, 2004, 05:34 PM
Awesome! Thanks!
massive3215
November 15th, 2004, 04:49 PM
Maybe someone can help me out with this slightly more complex _parent problem. On my main timeline I have defined the following variable: brazilState = 0;
Within the movie clip worldLarge_mc: I have the movie clip mainMap_mc and a button called return.
Within the movie clip mainMap_mc I have a button (brazil_btn) that has the following code:
on (release) {
if (_parent._parent.brazilState == 0) {
_parent._parent.worldLarge_mc.gotoAndPlay("brazilGo");
_parent._parent.brazilState = 1;
}
}
on the return button inside worldLarge_mc I have the following code:
on (release) {
gotoAndPlay("brazilReturn");
_parent.brazilState = 0;
}
my problem is everything works fine the first time I click the brazil_btn and the return button but on subsequent clicks i have to double click the brazil_btn to get it to function. Does anyone know what the problem is?
3pinter
November 15th, 2004, 04:58 PM
maybe because of your "if(_parent._parent.brazilState ==0)" in your first button but which isn't present in your other one.
Try to add: "if(_parent._parent.brazilState ==1)"
massive3215
November 15th, 2004, 05:08 PM
I tried that and it didn't change anything. I still have to click the brazil_btn twice the 2nd time around to get it to work properly.
I'm even running a trace on the variable and the second time I click on the brazil_btn I have to click it twice to change the variable back to 1. Any other ideas?
ghjr
November 16th, 2004, 08:12 AM
Have you tried setting brazilState as a global variable just to test around. Then if that works, we know something with the pathing is wrong.
[]s
massive3215
November 16th, 2004, 11:35 AM
I've uploaded my file if you want to take a look at it (http://digitalarts.bgsu.edu/portfolios/jimmel/04.fla). I used trace on the mexico button and as you can see you have to click twice on the buttons to get them to change their variable.
I'm trying to get the buttons to not work if you have already clicked on one, and are zoomed in on the map. So you would have to click return before you can click on another button. Thanks for anyone who can help me!
ghjr
November 16th, 2004, 03:56 PM
I dont see any problems... I don't thin I understood whats going on. Whenever I click on a countries button, it zooms in. When I click on return it then zooms out. Then when I click on another country it zooms in again.
massive3215
November 16th, 2004, 04:08 PM
When you zoom in I want the other buttons to be disabled until you zoom out
ghjr
November 16th, 2004, 08:21 PM
Hmmm... that is strange. I'll take a better look tonight and if no one gets back to you on this will answer back tommorow.
Cheers.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.