The Graphics class is a native class (i.e., one implemented in C++, not in AS3) in the Flash Player. What do you mean that lineTo() commands create a circle by default? - Gordon
________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Rick Schmitty Sent: Wednesday, March 07, 2007 9:53 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Is the Graphics class available in the SDK anywhere? I'd like to extend the functionality of lineStyle to allow for a shape option. Drawing with the lineTo commands is ok, but that creates a circle by default, which leaves the only option of using drawRect and drawEllipse as methods for other strokes. This doesnt work too hot, if you run this example below you can see. Fast mouse movement breaks the line and after a while it becomes really laggy. Is there perhapse another way of doing this with AS3? <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " mouseUp="stopDraw(event)"> <mx:Script> <![CDATA[ private var isDrawing:Boolean=false; private var tool:Number=1; private function startDraw(event:MouseEvent):void { pad.graphics.moveTo(event.localX,event.localY); isDrawing=true; } private function onMouseMove(event:MouseEvent):void { if (!isDrawing) return; switch (tool) { case 1: pad.graphics.lineStyle(10,0xff0000,1); pad.graphics.lineTo(event.localX,event.localY); break; case 2: pad.graphics.lineStyle(1,0x00ff00,1); pad.graphics.beginFill(0x00ff00,1); pad.graphics.drawEllipse(event.localX,event.localY,25,5); break; case 3: pad.graphics.lineStyle(1,0x0000ff,1); pad.graphics.beginFill(0x0000ff,1); pad.graphics.drawRect(event.localX,event.localY,15,15); break; } } private function stopDraw(event:MouseEvent):void { isDrawing=false; } private function clear():void { pad.graphics.clear(); } ]]> </mx:Script> <mx:Panel title="Graphics Draw Test"> <mx:Canvas width="500" height="500" mouseDown="startDraw(event)" mouseMove="onMouseMove(event)" id="pad"> </mx:Canvas> <mx:ControlBar> <mx:Button label="Pencil" click="{tool=1}"/> <mx:Button label="Brush" click="{tool=2}"/> <mx:Button label="Square" click="{tool=3}"/> <mx:Button label="Clear" click="clear()"/> </mx:ControlBar> </mx:Panel> </mx:Application>