[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; 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,0xff,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,0xff,1); pad.graphics.beginFill(0xff,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
RE: [flexcoders] Is the Graphics class available in the SDK anywhere?
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,0xff,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,0xff,1); pad.graphics.beginFill(0xff,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
Re: [flexcoders] Is the Graphics class available in the SDK anywhere?
Ah, so even if you were to release the code, everyone would need my version of the flash player to get that effect I created? By circle I mean the rounded edge of the lineStyle creates. If you change line 17 (becomes more obvious with bigger sizes) in my example to something like pad.graphics.lineStyle(50,0xff,1); and draw a very short line, it makes a circle type effect (just due to the rounded edge of the line) You can change the caps property to square, which has some odd effects when drawing free form. pad.graphics.lineStyle(50,0xff,1,false,normal,square); Basically, I'd like to mimic the Flash IDE Brush Tool. You can select a circle (default), 2 ellipses, multiple rectangles and slanted rectangles as your brush stroke Wishlist? :) On 3/7/07, Gordon Smith [EMAIL PROTECTED] wrote: 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; 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,0xff,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,0xff,1); pad.graphics.beginFill(0xff,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
Re: [flexcoders] Is the Graphics class available in the SDK anywhere?
Extending the functionality of the graphics object is generally done creating a wrapper class that is passed the graphics object and then operates on it. There's an example for this out there that draws dotted lines. I'll see if I can find it. - Dan On 07 Mar 2007 11:49:56 -0800, Rick Schmitty [EMAIL PROTECTED] wrote: Ah, so even if you were to release the code, everyone would need my version of the flash player to get that effect I created? By circle I mean the rounded edge of the lineStyle creates. If you change line 17 (becomes more obvious with bigger sizes) in my example to something like pad.graphics.lineStyle(50,0xff,1); and draw a very short line, it makes a circle type effect (just due to the rounded edge of the line) You can change the caps property to square, which has some odd effects when drawing free form. pad.graphics.lineStyle(50,0xff,1,false,normal,square); Basically, I'd like to mimic the Flash IDE Brush Tool. You can select a circle (default), 2 ellipses, multiple rectangles and slanted rectangles as your brush stroke Wishlist? :) On 3/7/07, Gordon Smith [EMAIL PROTECTED] wrote: 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; 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,0xff,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,0xff,1); pad.graphics.beginFill(0xff,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
RE: [flexcoders] Is the Graphics class available in the SDK anywhere?
Wishlist? Yep. - Gordon From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Rick Schmitty Sent: Wednesday, March 07, 2007 11:48 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Is the Graphics class available in the SDK anywhere? Ah, so even if you were to release the code, everyone would need my version of the flash player to get that effect I created? By circle I mean the rounded edge of the lineStyle creates. If you change line 17 (becomes more obvious with bigger sizes) in my example to something like pad.graphics.lineStyle(50,0xff,1); and draw a very short line, it makes a circle type effect (just due to the rounded edge of the line) You can change the caps property to square, which has some odd effects when drawing free form. pad.graphics.lineStyle(50,0xff,1,false,normal,square); Basically, I'd like to mimic the Flash IDE Brush Tool. You can select a circle (default), 2 ellipses, multiple rectangles and slanted rectangles as your brush stroke Wishlist? :) On 3/7/07, Gordon Smith [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: 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:flexcoders@yahoogroups.com http://yahoogroups.com ] 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,0xff,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,0xff,1); pad.graphics.beginFill(0xff,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
Re: [flexcoders] Is the Graphics class available in the SDK anywhere?
Submitted to wishlist, thanks for your help Gordon. Dan, I think you are thinking of this example by Ely: http://www.quietlyscheming.com/blog/charts/dashed-lines/ While very very cool, it still uses lines and the line function, which is the root of what I'm trying to behave different On 07 Mar 2007 12:43:46 -0800, Gordon Smith [EMAIL PROTECTED] wrote: Wishlist? Yep. - Gordon -- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Rick Schmitty *Sent:* Wednesday, March 07, 2007 11:48 AM *To:* flexcoders@yahoogroups.com *Subject:* Re: [flexcoders] Is the Graphics class available in the SDK anywhere? Ah, so even if you were to release the code, everyone would need my version of the flash player to get that effect I created? By circle I mean the rounded edge of the lineStyle creates. If you change line 17 (becomes more obvious with bigger sizes) in my example to something like pad.graphics.lineStyle(50,0xff,1); and draw a very short line, it makes a circle type effect (just due to the rounded edge of the line) You can change the caps property to square, which has some odd effects when drawing free form. pad.graphics.lineStyle(50,0xff,1,false,normal,square); Basically, I'd like to mimic the Flash IDE Brush Tool. You can select a circle (default), 2 ellipses, multiple rectangles and slanted rectangles as your brush stroke Wishlist? :) On 3/7/07, Gordon Smith [EMAIL PROTECTED] wrote: 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; 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,0xff,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,0xff,1); pad.graphics.beginFill(0xff,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