Flex: Why is line obscured by canvas' background

Posted by mauvo on Stack Overflow See other posts from Stack Overflow or by mauvo
Published on 2010-03-22T00:52:17Z Indexed on 2010/03/22 1:01 UTC
Read the original article Hit count: 321

Filed under:
|
|
|

I want MyCanvas to draw lines on itself, but they seem to be drawn behind the background. What's going on and how should I do this?

Main.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:my="*">
    <my:MyCanvas width="300" height="300" id="myCanvas"></my:MyCanvas>
    <mx:Button label="Draw" click="myCanvas.Draw();"></mx:Button>
</mx:Application>

MyCanvas.as

package  
{
    import mx.containers.Canvas;
    public class MyCanvas extends Canvas
    {
        public function MyCanvas() 
        {
            this.setStyle("backgroundColor", "white");
        }
        public function Draw():void
        {
            graphics.lineStyle(1);
            graphics.moveTo( -10, -10);
            graphics.lineTo(width + 10, height + 10);
        }
    }
}

Thanks.

© Stack Overflow or respective owner

Related posts about flex

Related posts about actionscript-3