Drawing in Flex using the UIComponent

Draw a line in flex


I was asked by a fellow coldfusion buddy if it was possible to take an image into flash, and be able to draw on it, i said absolutely…

They basically have a stock chart that they want to draw straight lines on… I don’t know much about charting or stock trading, but it’s what they wanted… the project never went through for this simple step, they took a great bid that we through out, and we’re going to do some full on flex charting for them…

my plan for the line tool was to just bring in the image, and said a UIComponent over it, and then they could draw on it… they said there was no purpose of saving the data… it was a strange thing….. but anyway… this is the starts of that project.

(note: these links are the sames as the ones at the top, they are just here in case the blog gets long)


6 comments on this post.
  1. PaulH:

    well if it’s a chart, i would have used its data canvas, working in data space is sometimes more useful than image space.

  2. you are kidding right:


    Really really?

    It takes THAT MUCH effort to draw a line on an image?

    Good lord, I’m staying away from Flex.

  3. dan:

    Hey man thanks a lot for this code.

    I’m creating something kinda similar and this really helped!

  4. Wilensky:

    Thanks alot! You’ve helped me with this thing.

    I was “drawing” lines as Sprite() and Shape() and can’t addChild on my scene as I want.

    After implementing the line over UIComponent it works great.

    Thanks alot!

    Here is the code. I needed to draw a line on MouseEvent. I performed it inside class and add to the scene where the button was clicked.

    var line:UIComponent = new UIComponent();
    line.graphics.lineStyle(2, 0x990000, .75);
    line.graphics.moveTo(-10, -10);
    line.graphics.lineTo(200, 200);


  5. Tahir Alvi:

    nice work

  6. Basava:

    i loaded a image on canvas on a button click n trying to draw a line on the image…i am not getting …help me out

Leave a comment