PDA

View Full Version : Scoping and enable button


shorescores
01-28-2009, 09:08 PM
Newbie question - I can't re-enable a button inside of an external swf. As brief as I can describe my FLA structures below:

My main movie is "home.swf" The root timeline contains a preloader and an empty movie clip, "container_mc" Inside "container_mc" is a navigation menu with buttons. I want the button "highlightTemp_btn" to disable after loading an external SWF - the ActionScript:

// Nav
highlightTemp_btn.onRelease = function() {
loadMovie("Highlight_TempLang.swf", 1);
highlightTemp_btn.enabled=false;
};

Works fine - the external SWF plays on Level 1, and the instance of highlightTemp_btn is disabled.

Inside the external SWF, named "Highlight_TempLang.swf", I have a root timeline with a preloader and an empty movie clip, "container_mc" Inside of "container_mc" is a button, "close_btn" which closes the swf on Level 1 and returns to the home page on Level 0.

MY PROBLEM: I can't re-enable the highlightTemp_btn in my main movie, most likely because I am not correctly targeting it:

// close the MC on Level 1 and enable highlightTemp_btn
close_btn.onRelease = function() {
unloadMovieNum(1);
_parent._parent._parent.highlightTemp_btn.enabled= true;
trace("OFF");
};

** I have tried various multiples of "_parent." to try and get that highlightTemp_btn to work. I have also tried using levels. Since my "home.swf" uses a "container_mc" where the "highlightTemp_btn" exists, I am failing to target it.

Currently this is being published for Flash 6 (a sad and different story).

Any help is greatly appreciated!

- shorescores

RefreshGFX
01-29-2009, 02:03 AM
Honestly, I don't know if this is going to work or not... But, try ...

close_btn.onRelease = function() {
_level0.highlightTemp_btn.enabled=true;
unloadMovieNum(1);
trace("OFF");
};

You could also try ...

_level0.container_mc.highlightTemp_btn.enabled=tru e;

_root.container_mc.highlightTemp_btn.enabled=true;

I think one of those may work for you.

shorescores
01-29-2009, 02:44 AM
RefreshGFX,

Thanks a zillion! You have given me a lesson in dealing with Scope to remember forever.

This ActionScript does the trick:
// close_btn goes to main swf (Level 0)
// then goes into container_mc
// and into highlightTemp_btn to re-enable it
close_btn.onRelease = function() {
_level0.container_mc.highlightTemp_btn.enabled=tru e;
unloadMovieNum(1);
};