PDA

View Full Version : Senocular's Path Class



DaveSchwartez
February 15th, 2010, 04:01 PM
While starting work on one of the projects, I stumbled upon senocular's link:

http://www.senocular.com/flash/actionscript/?file=ActionScript_3.0/com/senocular/drawing/Path.as

While this is sweet, I was wondering if it possible to write up some AS that will take line paths that you have drawn and convert them into a Path object? For example say you drew a jagged line from left to write, would there be a way to have AS convert that into a Path object.

Thanks in advance,
Dave

radd
August 19th, 2010, 11:36 AM
Hi Dave,
Did you found a solution on this?

senocular
August 19th, 2010, 11:37 AM
There are extensions (well, at least one) that will do this. I don't know them offhand, but you should be able to google them.

senocular
August 19th, 2010, 11:44 AM
^ the above is for Flash. I've actually made one myself for fireworks:
http://www.senocular.com/fireworks/extensions/?entry=573
(though this uses the new API and not that which is compatible with the Path class. It would at least get you the points which you could write a little code to convert to DAPI1 commands)

radd
August 20th, 2010, 06:28 AM
Thanks for pointing me to your extension.
Well, it generated me a very nice AS file (attached)
What do I do with it now?

I presume (in fact, I know) it's not easy to animate such a thing but as a novice I don't even know what to google for. I never heard about "DAPI1 commands".

senocular
August 20th, 2010, 09:24 AM
DAPI1 is in reference to "drawing API 1", or the old drawing commands. My extension uses DAPI2, the new drawing commands. You would need to convert between the two. You should be able to write a little as loop that can do this for you.

radd
August 25th, 2010, 09:43 AM
yes, but even if I convert between the two drawingAPIs in order to use your Path.as, I don't know how will that help me to animate my path. If you remember it's about a long hairy line that should start growing from a point, follow all curves and reveal towards the end point.

thanks to the extension I now have all points as a Vector typed array, but from there to the animation... ?!
I read that the Path.as can "draw" segments etc. or make an object follow it.

senocular
August 25th, 2010, 09:59 AM
Right. Use the drawing commands to add the path to the path class then have the path class draw them.

radd
August 25th, 2010, 10:06 AM
sorry for being annoying (if anything, i'm too novice)
ok, but i need some sort of animation. I don't know how to do that.
From this bit: http://swfaddress.arb-tb.ro/lfi001string.jpg [...] working the points out [...] to this sort of stuff: http://www.slipkangourou.be/fil.swf

is it possible with your class?

senocular
August 25th, 2010, 10:16 AM
yes - that's what all of this has been about so far.

... but it looks like you already have it?

radd
August 25th, 2010, 11:39 AM
that one looks odd; also it's too long and it's done on an EnterFrame event.

First, I drew the path by hand, added it as a guide on timeline over to a ball_mc, and on an event EnterFrame I drew moveTo lines using the x,y of ball_mc. The animation needs to run much faster so if I reduce the frames the ball will obviously cut some corners. Even with 30'' of animation like in the demo above you can see it's not clean. I need a pure AS solution.

That's why I needed your help.

senocular
August 25th, 2010, 11:57 AM
Then you can use the path class. The path class requires you use lineTo, curveTo, etc. to define the path in the class before it can be drawn. This is why there's a conversion necessary from the command extension I linked to for going from the vector data to those calls.