A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Enable and Disable buttons

  1. #1
    Senior Member
    Join Date
    Jul 2001
    Location
    Planet Earth
    Posts
    298

    Enable and Disable buttons

    my buttons disable but ignore the gotoAndStop...what is wrong here
    Code:
    private function activateLanguageButtons(){
    	for (var a:Number=1;a<languages.length; a++){
    		this["btn"+a].id = a;
    		this["btn"+a].buttonMode = true;
    		this["btn"+a].addEventListener(MouseEvent.ROLL_OVER, rollOn);
    		this["btn"+a].addEventListener(MouseEvent.ROLL_OUT, rollOff);
    		this["btn"+a].addEventListener(MouseEvent.CLICK, setLanguage);
    	}
    }
                  
    private function setLanguage(evt:Event){
    	selectedLanguage = languages[evt.target.id];
    	// show the button as selected
    	for (var i:Number=1;i<languages.length; i++){
    		if (this["btn"+i].id == evt.target.id){
    			this["btn"+i].gotoAndStop(2);
    			this["btn"+i].mouseEnabled = false;
    		} 
    		else {
    			this["btn"+i].gotoAndStop(1);
    			this["btn"+i].mouseEnabled = true;
    		}
    	}
    }
    
    activateLanguageButtons();
    
    
    function rollOn(evt:MouseEvent){
    	evt.target.gotoAndStop(2);
    }
    		
    function rollOff(evt:MouseEvent){
    	evt.target.gotoAndStop(1);
    }
    ---
    Thinking outside of the box will get you fired if the "box" is strict budget.

  2. #2
    Senior Member
    Join Date
    Jul 2001
    Location
    Planet Earth
    Posts
    298

    resolved [solved]

    Code:
    private function activateLanguageButtons(){
    	for (var a:Number=1;a<languages.length; a++){
    		this["btn"+a].id = a;
    		this["btn"+a].buttonMode = true;
    		this["btn"+a].addEventListener(MouseEvent.ROLL_OVER, rollOn);
    		this["btn"+a].addEventListener(MouseEvent.ROLL_OUT, rollOff);
    		this["btn"+a].addEventListener(MouseEvent.CLICK, setLanguage);
    	}
    }
    private function setLanguage(evt:Event){
    	selectedLanguage = languages[evt.target.id];
    	// show the button as selected
    	for (var i:Number=1;i<languages.length; i++){
    		if (this["btn"+i].id == evt.target.id){
    			this["btn"+i].gotoAndStop(2);
    			this["btn"+i].mouseEnabled = false;
    			this["btn"+i].removeEventListener(MouseEvent.ROLL_OUT, rollOff);
    			this["btn"+i].removeEventListener(MouseEvent.ROLL_OVER, rollOn);
    					
    		} 
    		else {
    			this["btn"+i].gotoAndStop(1);
    			this["btn"+i].mouseEnabled = true;
    			this["btn"+i].addEventListener(MouseEvent.ROLL_OVER, rollOn);
    			this["btn"+i].addEventListener(MouseEvent.ROLL_OUT, rollOff);
    		}
    	}
    }
    		
    
    activateLanguageButtons();
    
    
    function rollOn(evt:MouseEvent){
    	evt.target.gotoAndStop(2);
    }
    ---
    Thinking outside of the box will get you fired if the "box" is strict budget.

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