So it turns out that Flex ignores the skin size if it less than 12.  You
can ask the skin for its measuredWidth/Height and you'll get the right
number, but the measure() method ignores it.

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of ben.clinkinbeard
Sent: Friday, January 25, 2008 7:50 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Seriously, what is the 'right' way to do
default styles?

 

It seems that Flex 2 does in fact autosize, but it has a minimum size
of 12 x 12 to do so. If you assign an image whose dimensions are
smaller than that as a skin, the button will be scaled up to 12 x 12
if you don't provide an explicit size. This holds true in Flex 2, HF 1
through 3. Flex 3 will autosize anything, all the way down to a 1 x 1
skin.

I was using the simple test app below and adjusting the size of
closeButton.png to test. Luckily, my skins are currently 10 x 10 and I
think resaving them as 12 x 12 should be OK. Interesting nonetheless.

Ben

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
layout="absolute"
creationComplete="init()">
<mx:Style>
Button
{
upSkin: Embed(source="closeButton.png");
overSkin: Embed(source="closeButton.png");
downSkin: Embed(source="closeButton.png");
disabledSkin: Embed(source="closeButton.png");
}
</mx:Style>
<mx:Script>
<![CDATA[
private function init():void
{
trace(btn.getExplicitOrMeasuredWidth(),
btn.getExplicitOrMeasuredHeight());
}
]]>
</mx:Script>
<mx:Button id="btn" />
</mx:Application>

 

Reply via email to