Posts Tagged ‘vector’

Chad Upton

Creating an HRule in MXML with Spark Components

Tuesday, January 10th, 2012

By Chad Upton – senior consultant

Although there is an MX HRule component, there is not a Spark equivalent. You could still use the mx component, but it’s better to use a vector graphic for something as simple as a straight line – particularly if you’re building a mobile application.

For a horizontal rule, you can simple set the width of the line, the color, and the weight (stroke/thickness).

1
2
3
4
5
<s:Line width="100%">
    <s:stroke>
        <s:SolidColorStroke color="0x000000" weight="2"/>
    </s:stroke>
</s:Line>

You can also draw a line from point to point:

1
2
3
4
5
<s:Line xFrom="10" xTo="20" yFrom="10" yTo="20">
    <s:stroke>
        <s:SolidColorStroke color="0xFF0000" weight="1"/>
    </s:stroke>
</s:Line>

Be sure to “like” us on facebook to stay in the loop and checkout our course calendar for flex, html5, javascript, and other platform training programs — online and in the classroom.