views:

540

answers:

1

So below is the code I have so far. For now I simply want to make it draw a square and have it show up. Right now when I click the area defined in MXML as <components:PaintArea width="100%" height="100%" id="paint-a"></PaintArea> it shows nothing; however, the actionlistener is getting triggered and an element is being added to the group. Not sure exactly what is going on... perhaps for some reason it doesn't think the element is drawable? Anyways thanks for the help!

public class PaintArea extends SkinnableContainer
{
    private var canvas:Group;

    public function PaintArea()
    {
        super();
        canvas = new Group();
        canvas.clipAndEnableScrolling = true;
        canvas.percentHeight = 100;
        canvas.percentWidth = 100;
        canvas.addEventListener(MouseEvent.MOUSE_UP,drawRectangle);
        this.addElement(canvas);
    }

    private function drawRectangle(e:MouseEvent):void{
        var r:Rect = new Rect();
        r.fill = new SolidColor(0x00ff00,.5);
        canvas.addElement(r);
    }
}
+2  A: 

You should probably set the width and height of the rectangle r.

Robert Bak
wow ... yea duh! Thanks :)!
Parris