A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Need help with declaring var for multiple functions

Threaded View

  1. #1
    Member
    Join Date
    Nov 2007
    Posts
    83

    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
    Last edited by onurcan1977; 04-13-2011 at 04:45 PM. Reason: what i m using

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center