當使用mx:HRule或mx:VRule時,Flash Builder建議使用s:行代碼。 我爲什麼要編寫這樣的東西:的爲什麼使用s:Line而不是mx:HRule?
<s:Line xFrom="0" xTo="245" yFrom="0" yTo="1"/>
代替
<mx:Hrule width="100%" />
如何獲得相對大小? (百分比)
當使用mx:HRule或mx:VRule時,Flash Builder建議使用s:行代碼。 我爲什麼要編寫這樣的東西:的爲什麼使用s:Line而不是mx:HRule?
<s:Line xFrom="0" xTo="245" yFrom="0" yTo="1"/>
代替
<mx:Hrule width="100%" />
如何獲得相對大小? (百分比)
因爲mx組件正逐步淘汰以獲得更好的可換膚Spark組件。爲什麼你不能在Line中使用width = 100%?順便說一下,該線段不會顯示任何內容,因爲您沒有設置中風。這是我想你想:
<s:Line width="100%">
<s:stroke>
<s:SolidColorStroke color="#000000" weight="1" caps="square"/>
</s:stroke>
</s:Line>
如果你真的只是想它只是一個標籤,你總是可以創建一個新的組件,稱之爲HRule
並有一個默認的風格吧。
那麼你不想寫這樣的東西......
我可能會寫更多這樣的..
<s:Line width="100%">
<s:stroke>
<s:SolidColorStroke caps="none" color="#AF0000" joints="miter" miterLimit="4"
weight="2"/>
</s:stroke>
<s:filters>
<s:BevelFilter angle="45.0" blurX="1" blurY="1" distance="1"
highlightAlpha="1.0" highlightColor="#FFFFFF" knockout="false"
quality="2" shadowAlpha="1.0" shadowColor="#000000" strength="1"
type="inner"/>
</s:filters>
</s:Line>
但它真的取決於你。任何火花形狀基元都可以使用相對定位和大小來編寫。
編輯
賈克斯打我吧:)
我使用S有樣的一個bug:線元素,它沒有填滿100%,我的皮膚裏。 我用S代替它:SkinableContainer元素是這樣的:
<s:SkinnableContainer backgroundColor="Lime" width="100%" height="10"/>
我發現這對我來說是一個很好的解決方案,而且它也是在這樣的代碼你提到你想節省空間。
好的,謝謝。但是,對我來說,看起來像是一個簡單的「線條」的很多文本。 – 2011-05-24 14:03:52
這是,但同樣,這是爲了使您的線路可以非常可定製,從長遠來看更好。如果你想要一個'標準化'的行,只需創建一個可重用的自定義組件。 – 2011-05-24 14:09:55
@ Zenklys:你只需要做一次。從中創建一個組件,然後使用該組件。 – 2011-05-24 14:11:07