Need help with declaring var for multiple functions
hi, how to declare a variable that can be accessible for some functions, and recreatible with "new" command, using or without using packages?
Code:
function showWindow(event:MouseEvent):void {
currentButton = event.target.name;
var holder:DisplayObjectContainer=new DisplayObjectContainer();
addChild(holder);
loader = new SWFLoader("swf/showwindow.swf", {onComplete:onLoadSWF, container:holder, width:200, height:200, x:0, y:0, hAlign:"left", vAlign:"top", centerRegistration:true});
addChild(loader.content); //add the ContentDisplay to the display list even before raw content is loaded.
loader.load();
}
function onLoadSWF(event:LoaderEvent):void {
mc = loader.rawContent; //the root of the child swf
mc.close_btn.addEventListener(MouseEvent.CLICK, closeSwf);
mc.topBar_mc.addEventListener(MouseEvent.ROLL_OVER, rollOverHandler);
mc.topBar_mc.addEventListener(MouseEvent.MOUSE_MOVE, follow);
mc.topBar_mc.addEventListener(MouseEvent.ROLL_OUT, rollOutHandler);
setChildIndex(cursor_mc, numChildren-1);
holder.x=200;
holder.y=200;
// Detect which button was clicked
if (currentButton=="instanceCapitalLettersShow") {
mc.show_txt.text=onCapitalClick();
} else if (currentButton=="instanceSmallLettersShow") {
mc.show_txt.text=onSmallClick();
} else if (currentButton=="instanceNumbersShow") {
mc.show_txt.text=onNumbersClick();
}
}
my problem is two functions can't use one variable "holder". can anyone help me?
i m using greensock swfloader