Why use s:Line instead of mx:HRule?

i.am.michiel picture i.am.michiel · May 24, 2011 · Viewed 8.3k times · Source

When using a mx:HRule or mx:VRule, Flash Builder suggests using a s:Line instead. Why would I want to write stuff like this :

<s:Line xFrom="0" xTo="245" yFrom="0" yTo="1"/>

instead of

<mx:Hrule width="100%" />

How do I get relative sizes ? (percent)

Answer

J_A_X picture J_A_X · May 24, 2011

Because mx components are being phased out for the better, skinnable Spark components. And why can't you use width=100% with Line? Btw, that line segment won't show anything because you don't have a stroke set. Here's what I think you want:

<s:Line width="100%">
   <s:stroke>
      <s:SolidColorStroke color="#000000" weight="1" caps="square"/>
   </s:stroke>
</s:Line>

If you really just want to make it just one tag, you could always create a new component, call it HRule and have a default style to it.