user1166528
user1166528

Reputation: 381

How to Draw a straight line in Flex with out Action script

Is it possible to draw a straght line from one point to another point in Flex with out using Action Script (I am wondering is there any kind of Flex tag is there). Please forgive me if it is a dumb question as i am totally new in Flex

Upvotes: 0

Views: 223

Answers (1)

Josh
Josh

Reputation: 8149

Completely off the top of my head and untested, but this is how you do it. This will create a path from (10, 10) to (20, 10). M is the equivalent of graphics.moveTo and L is the equivalent of graphics.lineTo.

Not sure if the fill will create anything because the path is technically 0px tall, so you might have to add a L 20 11 L 10 11, but this is enough to give you an idea. Alternatively, using Spark Stroke may do the same without the added lines.

<s:Graphic>
    <s:Path data="
            M 10 10
            L 20 10"/>
        <s:fill>
            <s:SolidColor color="#000000"/>
        </s:fill>
    </s:Path>
</s:Graphic>

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/primitives/Path.html

http://help.adobe.com/en_US/flex/using/WS5B6A8436-0FF5-4029-8524-C7C1106C483D.html

You can bind data within the data tags as well, so you could do a data="M 0 0 L {this.width} {this.height}" to go from corner to corner (and have it auto-scale with the window)

Upvotes: 2

Related Questions