I’ve made ToggleButton by extending SimpleButton class, but I’ve noticed strange behavior: when you remove SimpleButton from stage, and add it again it appears in Over State… anyone knows why?
Here’s simple test code (make two instances btn1, btn2 of any button symbol with diferent states - to notice difference ):
import flash.events.MouseEvent;
import flash.display.DisplayObject;
import flash.events.Event;
import flash.display.SimpleButton;
btn1.addEventListener(MouseEvent.CLICK, onBtn1Click);
btn2.addEventListener(MouseEvent.CLICK, onBtn2Click);
function onBtn1Click(event:MouseEvent):void {
var tempState:DisplayObject = btn1.upState;
btn1.upState = btn1.downState;
btn1.downState = tempState;
removeChild(btn1);
}
function onBtn2Click(event:MouseEvent):void {
addChild(btn1); // appears on stage in overState ???
}
I’ve temporary solved the issue by making new variable and assigning btn1.overState to it on Event.REMOVED_FROM_STAGE; then assigning it back on MouseOver once it’s added to stage… But seams kinda stupid thing to do ((: