Do you know about this weird thing. "AS3, Button width cannot change by setStyle(). However, inline CSS can change width."

StackOverflow https://stackoverflow.com/questions/20737411

質問

I'm making GraphPaper like WEBapp and notice.


<?xml version="1.0" encoding="utf-8"?>
<s:Application name="test2"
  xmlns:fx="http://ns.adobe.com/mxml/2009" 
  xmlns:s="library://ns.adobe.com/flex/spark"
  xmlns:mx="library://ns.adobe.com/flex/mx">
    <mx:Button width="500" height="500" />
</s:Application>

can make big square Button.

But


<?xml version="1.0" encoding="utf-8"?>
<s:Application name="test2"
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Style>
        @namespace mx "library://ns.adobe.com/flex/mx";
            mx|Button {
                width: 500;
            }
    </fx:Style>
    <mx:Button />
</s:Application>

This doesn't work

And


<?xml version="1.0" encoding="utf-8"?>
<s:Application name="test2"
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Style>
        @namespace mx "library://ns.adobe.com/flex/mx";
            mx|Button {
                fontSize: 500;
                width: 500;
            }
    </fx:Style>
    <mx:Button label="test" />
</s:Application>

can extend button width 'just similar to text width'.

Thus I predict that Button's width can be defined by fontSize or icon. Button itself width cannot be change externally. But inline CSS only can change Button's width irregularly.

I think this is Adobe's bug. How do you thin about this and do you know something about this problem?

役に立ちましたか?

解決

I may be corrected, but I believe inline CSS operates on the StyleManager to pass operations to the SkinClass using the ISimpleStyleClient interface. IE using the .getStyle() and .setStyle() functions. Height and Width are not part of the StyleManager they are properties of the DisplayObject.

MXML allows you to mix calls to class properties and skin/style properties inline, but CSS doesn't

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top