# SimpleButton strange behavior

**URL:** <https://forum.kirupa.com/t/simplebutton-strange-behavior/316006>\
**Category:** flash\
**Created:** [November 10, 2010, 2:26am UTC](https://forum.kirupa.com/t/simplebutton-strange-behavior/316006 "2010-11-10T02:26:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sasxa](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sasxa](https://forum.kirupa.com/u/sasxa)\
**Post date:** [November 10, 2010, 2:26am UTC](https://forum.kirupa.com/t/simplebutton-strange-behavior/316006/1 "2010-11-10T02:26:35Z")

</div>

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 😛 ):

```auto

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 ((:
