Hello all, this is my first time posting, but not my first visit to the site. I do have a problem.
I’m trying to get a set of dynamically generated MCs that are nested about 4 levels down to use a function defined in the main timeline.
Here’s the main timeline code (parts not related are missing):
var domesticLangVar:String = new String();
domesticLangVar = "USA";
var invokeLanguage:MovieClip = new MovieClip();
invokeLanguage.addEventListener(Event.ENTER_FRAME, languageSelector);
addChild(invokeLanguage);
function languageSelector(event:Event):void {
trace(domesticLangVar);
invokeLanguage.removeEventListener(Event.ENTER_FRAME, languageSelector);
this.topBar_mc.langpicker_mc.flagimgholder_mc.addChild(flagimg);
}
Here is the button’s code:
import flash.events.MouseEvent;
var nationLangVar:String;
var thumbImageVar:String;
var domesticLangVar:String;
var img = new Loader();
img.load(new URLRequest(thumbImageVar));
flag_img.addChild(img)
invisflag_btn.buttonMode = true;
invisflag_btn.mouseChildren = false;
invisflag_btn.addEventListener(MouseEvent.CLICK , flagbuttonClick);
function flagbuttonClick(event:MouseEvent):void {
domesticLangVar = nationLangVar;
(root as MovieClip).invokeLanguage.addEventListener(Event.ENTER_FRAME, languageSelector);
var sndClick:click_snd = new click_snd();
sndClick.play();
(root as MovieClip).topBar_mc.langpicker_mc.langpalette_mc.gotoAndPlay("flagsup");
(root as MovieClip).topBar_mc.langpicker_mc.flagarrow_direction.gotoAndStop(1);
}
invisflag_btn.addEventListener(MouseEvent.MOUSE_OVER , flagbuttonOver);
invisflag_btn.addEventListener(MouseEvent.MOUSE_OUT , flagbuttonOut);
function flagbuttonOver(event:MouseEvent):void {
var sndOver:over_snd = new over_snd();
sndOver.play();
flaghighlight_mc.gotoAndStop(2);
}
function flagbuttonOut(event:MouseEvent):void {
flaghighlight_mc.gotoAndStop(1);
}
The reason I have the initial invokeLanguage event listener is because I have a detect via flashvars for the user’s default language. I want the user to be able to change the language, but I don’t want to have to have the function code in two places…that would be a mess. My thinking was to change the domesticLangVar and add the invokelanguage event listener again, but alas, the flash flayer is looking for the function in the nested button and can’t find it. How do I point flash into the right direction?