This content has been marked as final. Show 3 replies
Try putting your width setting directly after you set your hit states. Prior to this point, your button doesn't contain a single pixel of content. As a result, width and height can't be adjusted.
What confuses me is why the button does NOT show up at all. I thought the width set too early would be ignored and newly calculated width (by flash) take effect.
Setting it after addChild() works - that make me think flash play has some assumptions on w/h when creating a new displayObject.
You're using the simple button class. Just because you instantiate an object of this class doesn't mean you've added anything to the button.
What I'm trying to tell you is that addChild has nothing to do with it. Simple Button just happens to be dependent on what is defined inside the button states themselves.
For instance, comment out your hitStates leaving your width call after the addChild and you should notice the same behavior as before. By defining the button states, you are actually adding content to the container that will be drawn to the display when addChild is called.
You can define your height and width anytime after you have defined the states for the button. At this point, Flash will then have content to manipulate. Until you have drawable content to push to the display list, nothing will happen when width and height are called.