Wednesday, March 31, 2010

Flash Button Nightmare

I spent the day designing and implementing some GUI components for Pioneers. The buttons I designed had a downSkin which gives the illusion of being pressed:
The top box and the text in the last graphic are offset 2x1 pixels (but the shadow is in the same spot). I compensated for this offset by making sure the anchor of the MovieClip was in the same relative position.

I decided to use fl.controls.Button as my base class and apply the skins using the setStyle() function. I set width and height properties of the Button, and this was the result:
You can see the last skin is clearly stretched because the width and height are slightly less than the dimensions of the Button. As I said above, I compensated for this by changing the anchor, but that wasn't good enough. I even added a 0% (and later 1%) alpha box so the dimensions would line up. Had it worked, it would have been a dirty solution, but alas it still warped the skin a tiny bit.

The irony is that the old Button symbols in Flash would have worked with this no problem. I decided to try flash.display.SimpleButton, passing in the skins as constructor arguments.

Success! So if you have button skins of different sizes, use SimpleButton. The new Button Component is obviously too advanced to be bothered with these plebeian requests.

No comments:

Post a Comment