PDA

View Full Version : [FMX2004] Need help with blob-like effect



darkwood
January 5th, 2004, 06:46 AM
Hi everyone, the other day I was browsing the net and came upon this site Neave.com (http://www.neave.com/rant/), which has a really cool blob-like borders effect. I mailed the guy and he directed me to the actionscript source code (http://www.neave.com/lab/neave_site_fla.zip). Now the problem was that this was my first time looking at ActionScript code (heck... I didn't even know it existed!), so his code looks very cryptic for a total newbie like me.

I really wanted to learn how to accomplish this effect, so I decided to search the net for tutorials and instead of just copy-pasting his code, try and figure out how to do the effect and learn some ActionScript on the way.

Here's what I know as of now:

1. I must have an array of points, connect them using curveTo and fill it. For this I have to use this methods:

createMovieClip, lineStyle, beginFill, moveTo, curveTo, endFill

2. Then I must have a proximity detector for each point, more or less like:

dx = point._x - _xmouse;
dy = point._y - _ymouse;
distance = Math.sqrt(dx*dx + dy*dy);

and if the mouse is too close to the point make it move away with a certain velocity (but only if the mouse is moving, if it is still, just make the blob wobble for a while, using an elasticity effect).

point._vx += point._ax;
point._x += point._vx;

where the acceleration must be a fraction of the distance we calculated before:

k = .2; // example
point._ax = distance * k;

but we must also have damping so we can have the elastic movement, so:

damp = .9; // example

point._vx += point._ax;
point._vx *= damp;
point._x += point._vx;

3. Finally when the mouse is clicked on a blob we must communicate with the others and make them all wobble, by using LocalConnection. I saw some tutorials on this and if I have everything else working I don't think I'll have much problem implementing this part, since it is pretty straight forward.


Now, what I'm having trouble with is getting this all into code, like, how do i make the array with all the points and access them?; how do I inpose the proximity detector into each point and make the curveTo's change?

Any help on this would be much appreciated.



Note: There is a post (http://www.kirupaforum.com/forums/showthread.php?threadid=7273&highlight=blob) on this board regarding a blob, which more or less functions the way this is supposed to function, but the code is just way to weird for me to understand :(

senocular
January 5th, 2004, 06:54 AM
If this is your first time with ActionScript, you may want to take a step back and start from the beginning. Some people who've been using it for more than a year might not be able to accomplish that effect on their own, so it's not exactly "easy" and can confuse even the veterns.

First step might be reading through the intro to actionscript in Flash help.

Then you might want to look around for simple tutorials online which cover basic usage. Considering your circumstances, you'd want to focus on ones which deal with mouse movement and the drawing API (the commands used to dynamically draw lines like lineTo and curveTo). From there, you can start to get a foundation that will help you better understand that code you got from neave.


and welcome to the forums :)

darkwood
January 5th, 2004, 07:03 AM
Thanks for the hasty reply :)

I'm currently reading tutorials from kirupa.com, actionscript.org, actionscript-toolbox.com and were-here.com!

If you have any more sugestions, please post them! Thanks again.

senocular
January 5th, 2004, 07:08 AM
great places to start! :D
Theres also Flashkit.com which has a HUGE repository of both tutorials and files. The only problem there is that many are of older versions of Flash. You'd want to stick to MX and MX 2004 since MX was the first version of Flash that got the line drawing scripting added to it. Flash 5 might be ok for other basics though - things like mouse movement (hasnt changed since then).

I think you'll have your hands full for a while though. If you have any specific questions, feel free to ask on the forums. :D