PDA

View Full Version : drawing api help



harishcoorg
July 19th, 2007, 03:19 AM
Hi newbie to as3,

I want some help in drawing api please its urgent.

the problem is...

I've a drawing canvas say canvas_mc
I've 5-6 buttons say rect_mc, circle_mc, roundcornerrect_mc, line_mc, curve_mc

I want to draw some shapes like circle rectangle, rounded corner rectangle, line and curve on pressing the particular button mc's.

I want to draw these shapes on press dragging on the canvas_mc.

Even I want some anchor points for these so that I can edit it like scaling rotating.

please help me in this.

thanks and regards
Harish

efnx
July 19th, 2007, 02:08 PM
What have you tried so far? Once you give it a shot and hit a wall, we can help you around it. Start by making a square with resize buttons [anchor points], or something simple.

lettertwo
July 19th, 2007, 02:28 PM
I suppose I would start by creating MouseEvent handlers on the canvas_mc which trigger the drawing events. then:
1) have the press event create a new sprite and trigger listening for move event

2) the move would trigger drawing your shape (redrawing it completely each time you move the mouse, using the original x,y from click and the current mouseX,mouseY)

3) and finally the release event would simply remove the listener for the move event.

Obviously a simplified outline, but that's my initial thinking on it. as for adding anchor points, maybe once the mouse release event happens, draw your anchor points at the corners of your new sprite, and give them mouse listeners that either change the scale, with, height, rotation properties of the sprite, or trigger the drawing api to completely redraw the shape in your sprite based on the input from the user's mouse...

efnx
July 19th, 2007, 02:42 PM
sounds like a good start.

harishcoorg
July 20th, 2007, 03:26 AM
Hi thanks for your reply I am trying with that..

I have attached the script as txt file. for your reference.
I am getting confused by AS3

please help me

SquirtGun
July 20th, 2007, 12:22 PM
Hi harishcoorg!

check out these two links in the livedocs. They will help you achieve what you are going for. Apply these examples with what lettertwo suggested.

it takes time, but these will help you learn how AS3 works, particularly with the display list. .....that was one of the hardest concepts to wrap my head around.

Livedocs - Example: GeometricShapes (http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=04_OO_Programming_161_12.html)


Livedocs - Display Programming (http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=04_OO_Programming_161_12.html)

hope this helps.

~squirt

harishcoorg
July 24th, 2007, 05:59 AM
thanx buddy...



Hi harishcoorg!

check out these two links in the livedocs. They will help you achieve what you are going for. Apply these examples with what lettertwo suggested.

it takes time, but these will help you learn how AS3 works, particularly with the display list. .....that was one of the hardest concepts to wrap my head around.

Livedocs - Example: GeometricShapes (http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=04_OO_Programming_161_12.html)


Livedocs - Display Programming (http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=04_OO_Programming_161_12.html)

hope this helps.

~squirt