Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use s:Line instead of mx:HRule?

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)

like image 477
i.am.michiel Avatar asked May 24 '11 13:05

i.am.michiel


3 Answers

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.

like image 159
J_A_X Avatar answered Nov 07 '22 17:11

J_A_X


Well you wouldn't want to write stuff like that...

I would probably write it more like this..

<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>

But it's really up to you. Any of the spark shape primitives can be written using relative positioning and sizing.

edit

Jax beat me to it :)

like image 36
drkstr Avatar answered Nov 07 '22 17:11

drkstr


I had kind of a bug using the S:Line element, it didn't fill the 100% inside my skin. I replaced it with an S:SkinableContainer element like this:

<s:SkinnableContainer backgroundColor="Lime" width="100%" height="10"/>

I found it is a good solution for me, and it also saves space in the code like you mentioned you'd like.

like image 2
Shif Avatar answered Nov 07 '22 17:11

Shif