That would be my fault. I made improvements to make SimpleButton only appear if you pass in just one parameter on the upState. That means that if the downState or upState are null, the state won’t change, it will remain the same as the upState when you hover and click down on the mouse.
So in your first example, all you would do is:
var pb = new SimpleButton(b);
And that would work. Or should do.
I don’t think you can add the same object twice though, as you have done in your first example, if you uncomment line 1 and line 2 and 3, the second addChild call will be ignored because a Bitmap of the same instance has already been added to the stage.
I think we need to support sprite.hitArea (and similarly hitArea here for SimpleButton) to hit test on a totally different object, without affecting the addChild hierarchy.
As a fast workaround, perhaps if (hitTestState != overState && ... (etc) to not hide an object used for other states?
Honestly, I think the real thing here is that we need to be able to redirect hit testing logic to use a different object entirely.
I have a brand-new implementation of SimpleButton (just committed to GIT). With sprite.hitArea support in now (I think it basically works?) I used the same functionality to get our hitTestState behavior right. I moved SimpleButton to use InteractiveObject as the base class instead of DisplayObjectContainer, so it matches the proper parent, and also now behaves more like Flash.
If you add objects that are on the stage, these will be unparented as the button requires them. This is Flash’s behavior. They have a null parent when they are used as a state, and a hitTestState can remain parented (and displayed) elsewhere in the project, which is actually interesting.
Interested if there are any minor issues with the new code, but I think SimpleButton is now working how it should really behave, not as a quick workaround
We’re behind the curve on releases – pretty sure the new code has not gone live in a release just yet. Stay tuned, or try a development version of Lime/OpenFL if you want to try it out right away