PDA

View Full Version : AS Wave



abgen
July 10th, 2006, 06:04 AM
Hi,

I've recently finished a wave motion experiment, based on the work done by Yugo Nakamura (genius - http://www.yugop.com)

I've posted it a few places but forgot to do it for the folks here at Kirupa. Anyway, you can find the code at:

http://www.anygivenfriday.com/water2/

But if you would just like to look over the source code go to:

http://www.anygivenfriday.com/downloads/wave.zip

I was going to upload it but it exceeds the size allowance :(

I hope you enjoy this; I have started writing up this and my other experiments (http://www.anygivenfriday.com/elastic and http://www.anygivenfriday.com/torque)

Cheers

Paul

PS Any questions, please ask away!

phorte
July 10th, 2006, 06:11 AM
Very cool. Not very useful though really. But cool none the less.

abgen
July 10th, 2006, 06:14 AM
Now that's just not true; I've already had a good number of ideas for it. You just need to be a bit more creative. Oh, and its an experiment in motion and physics. As it stands, it's not supposed to be useful... just inspiring.

paranoid007
July 10th, 2006, 07:16 AM
That'll make a really sexy screensaver. Or a great background for a menu. Thank you for sharing ...

phorte
July 10th, 2006, 07:42 AM
I stand corrected, would make for some cool effects.

Berg
July 10th, 2006, 08:45 AM
avesome!!! thanks man, i was trying to make something similar, now i can learn from your code ;]

fluid_tw0
July 10th, 2006, 09:24 AM
idea:

drop a "ball" of some kind to it (black == liquid) - it would rock!

_this
July 10th, 2006, 09:55 AM
Great all this...
i loved torque! show us the source.. cold ?
;)

gvozden
July 10th, 2006, 10:28 AM
really really nice ;)

abgen
July 10th, 2006, 12:04 PM
@ _this:

Torque can be downloaded at: http://www.anygivenfriday.com/downloads/torque.zip

Just link it to a clip and away you go. FYI: You make the anchor point the Centre of Mass for the clip, normally in the middle of the MovieClip!

Paul

PS Remember to credit me if you use it for anything! Cheers!

pantas
July 10th, 2006, 12:35 PM
man this is awsome!
can it be interactive with contents? something like a motion tween that makes the water move as it passes by?

abgen
July 10th, 2006, 01:07 PM
Yeah, if you look at the code you'll find out how it reacts to the mouse. You could then use similar code to create waves. I will be adding in collision detection soon enough, which should make for some very interesting experiments!

-infect-
July 10th, 2006, 01:47 PM
looks great man. how long did it take you? any other experiments in the works?

SlowRoasted
July 10th, 2006, 01:51 PM
awesome stuff.

abgen
July 10th, 2006, 02:42 PM
looks great man. how long did it take you? any other experiments in the works?

It took an evening or two, after work. http://www.anygivenfriday.com/elastic and http://www.anygivenfriday.com/torque are the other two, but there's more in my head. I intend to wrap all these things up later into some simple-to-use way!

_this
July 10th, 2006, 03:54 PM
what can i do to link my clips to torque.as ?

fluid_tw0
July 10th, 2006, 04:35 PM
#import torque.as

possibly :)

_this
July 10th, 2006, 04:50 PM
hmmm ... after imported the link with clips ... doing ... how ?

abgen
July 10th, 2006, 05:56 PM
hmmm ... after imported the link with clips ... doing ... how ?

No, you need to go to the library and right click on the movieclip, and then select linkage. You need to put com.anygivenfriday.physics.Torque in the field. Then you need to put the Torque file in a folder structure: com/anygivenfriday/physics and the com folder should be in the same folder as your fla.

Hope that helps you, my man.

Paul

deAd
July 12th, 2006, 05:39 PM
Are you planning to post the source for the elastic? That looked really useful:*(

abgen
July 12th, 2006, 06:36 PM
I do plan on releasing this, and some other stuff. Just making a mini-site for it all :hugegrin:

Will post when it's live!

Cheers

Paul

jaydoh
July 12th, 2006, 11:53 PM
I do plan on releasing this, and some other stuff. Just making a mini-site for it all :hugegrin:

Will post when it's live!

Cheers

Paul


wow, this isn't your everyday flashkit crap either - nicely done~! :kommie:

abgen
July 13th, 2006, 04:11 AM
Ha ha. Thanks. You made me laugh! :D :shifty:

_this
July 13th, 2006, 09:10 AM
right and great ! work fine .. but the object when moved go outside the stage...
see sample . what can i do . Tks 4 help!

(ABGEN if possible! can download your fla file ??
in: http://www.anygivenfriday.com/torque )

abgen
July 15th, 2006, 05:35 AM
right and great ! work fine .. but the object when moved go outside the stage...
see sample . what can i do . Tks 4 help!

(ABGEN if possible! can download your fla file ??
in: http://www.anygivenfriday.com/torque )

You need to set the bounds for the object:

private var objBounds:Object = {lx:0, hx:800, ly:0, hy:600};

is the line in the code and you ned to set hx to be the Stage.width and hy to be Stage.height, unless you want it bound to a smaller area.

Please note: I've had to fix a bug in the code so you'd be better downloading a new version from http://www.anygivenfriday.com/downloads/torque.zip

abgen
July 15th, 2006, 05:43 AM
I also checked your SWF. You need to make the registration point of the MC the Center! It has to match the centre of mass of the object. And up your framerate to about 41 to make it look nice.

Paul

_this
July 15th, 2006, 10:11 AM
i change code to: private var objBounds:Object = {lx:0, hx:Stage.width, ly:0, hy:Stage.height}; but no work fine yet. i put the registration point in CENTER of movieClip ... i may do anything ?

abgen
July 15th, 2006, 10:13 AM
i change code to: private var objBounds:Object = {lx:0, hx:Stage.width, ly:0, hy:Stage.height}; but no work fine yet. i put the registration point in CENTER of movieClip ... i may do anything ?

Did you download the latest version of the code?

_this
July 15th, 2006, 10:47 AM
YES ! DOWNLOADED.

THIS IS THE NEW CODE... BUT I MAY CHANGE "objBounds" VAR ?

abgen
July 15th, 2006, 12:47 PM
The easiest thing to do would be to just change the objBounds object, yes. Please could you also remove the code from your post? I am trying to keep a count of the copies downloaded from the site. If its available from here then that defeats the point.

Paul

_this
July 17th, 2006, 09:28 AM
i change to this:
ActionScript Code:

private var objBounds:Object = {lx:0, hx:Stage.width, ly:0, hy:Stage.height};




and export the attached file... and i ask: "Why?" the object cant dragged around the stage.

abgen
July 17th, 2006, 09:32 AM
Ok, I can drag that around the stage. Not entirely sure why it's not working for you, mate.

_this
July 17th, 2006, 09:56 AM
well.. but i can drag for the blue stage only .. but in allStage, in fullscreen drag for all stage. possible ?

abgen
July 17th, 2006, 10:30 AM
yes, in that case you need to do this in your FLA:


var sListener:Object = new Object();
sListener.onResize = function()
{
// assuming your clip is called mcClip
// set new bounds for bouncing!
mcClip.objBounds = {lx:0, ly:0, hx:Stage.width, hy:Stage.height};

}

_this
July 17th, 2006, 05:54 PM
why dont work in fullscreen?
:puzzle:

Anogar
July 18th, 2006, 02:26 AM
I love the torque one. :D

tri_usha
July 18th, 2006, 04:33 AM
Hello Everyone

This is a Excellent site to learn Flash, ActionScript, PHP ,etc. Yesterday I've joined and i learnt a lot.I want to cerate a storyBook in FlashMX using ActionScript can you help me in this regard.
Thank you.

_this
July 18th, 2006, 02:37 PM
why dont work in fullscreen?
:puzzle:

Any idea ?

abgen
July 18th, 2006, 03:49 PM
I have plenty of ideas, my man.


Stage.addListener(sListener); // adds the listener to the stage
Stage.align = "TL"; // makes the stage align to the top left

_this
July 19th, 2006, 08:11 AM
hmmm... i change the code and work fine:
ActionScript Code:

Stage.align = "TL";
Stage.scaleMode = "noScale";
onResize = function() {
    clip.objBounds = {lx:0, ly:0, hx:Stage.width, hy:Stage.height};
}
Stage.addListener(this);
onResize();





tks

weisswolfen
July 19th, 2006, 12:04 PM
Great sutff, but I tried to open wave_exp.fla with flash 2004 mx and returned -unespected file format- , any one knows what is _exp and how i can open the file?
Thanks


Hi,

I've recently finished a wave motion experiment, based on the work done by Yugo Nakamura (genius - http://www.yugop.com)

I've posted it a few places but forgot to do it for the folks here at Kirupa. Anyway, you can find the code at:

http://www.anygivenfriday.com/water2/

But if you would just like to look over the source code go to:

http://www.anygivenfriday.com/downloads/wave.zip

I was going to upload it but it exceeds the size allowance :(

I hope you enjoy this; I have started writing up this and my other experiments (http://www.anygivenfriday.com/elastic and http://www.anygivenfriday.com/torque)

Cheers

Paul

PS Any questions, please ask away!

_this
July 20th, 2006, 10:29 AM
unspected format... u use flash mx 2004 and try open flash 8 format.
i think that is it !

chrisclick
July 20th, 2006, 02:41 PM
how do i create more than one box to drag?

_this
July 20th, 2006, 03:14 PM
create other mclip and click in library w/ right button of mouse and select linkage ... post continous with normal process....

chrisclick
July 20th, 2006, 03:23 PM
Thanks! It worked.

It makes a pretty good display for pictures aswell...

Demo: Click for demo gallery using torque (http://www.pencaderweb.co.uk/samplegallery/)

Anogar
July 20th, 2006, 03:47 PM
Heheh. Cool display for pictures, sure. Good, I think not. ;)

My cats are upside down and it's a pain in the butt trying to get them right side up. :lol:

felipegm
July 21st, 2006, 10:34 AM
hmmm... i change the code and work fine:
ActionScript Code:

Stage.align = "TL";
Stage.scaleMode = "noScale";
onResize = function() {
    clip.objBounds = {lx:0, ly:0, hx:Stage.width, hy:Stage.height};
}
Stage.addListener(this);
onResize();





tks

Hi,

I´m trying to apply the effect in full screen too, but don´t know how to change this code. Where do I put it?
Tks

_this
July 22nd, 2006, 10:51 AM
Stage.align = "TL";
Stage.scaleMode = "noScale";
onResize = function() {
clip.objBounds = {lx:0, ly:0, hx:Stage.width, hy:Stage.height};
}
Stage.addListener(this);
onResize();

this code put in first frame in your fla*
remember >>> clip:MovieClip
if u have 2 movieclips the code ll:


Stage.align = "TL";
Stage.scaleMode = "noScale";
onResize = function() {
clip.objBounds = {lx:0, ly:0, hx:Stage.width, hy:Stage.height};
clip2.objBounds = {lx:0, ly:0, hx:Stage.width, hy:Stage.height};
}
Stage.addListener(this);
onResize();

abgen
July 24th, 2006, 10:38 AM
Very good. Two things: change the anchor point of the clip to the centre and also up your frame rate and it will be great :)


Thanks! It worked.

It makes a pretty good display for pictures aswell...

Demo: Click for demo gallery using torque (http://www.pencaderweb.co.uk/samplegallery/)

felipegm
July 24th, 2006, 11:23 AM
this code put in first frame in your fla*
remember >>> clip:MovieClip
if u have 2 movieclips the code ll:


Thanks a lot for the help! it works fine!

by the way, do you managed to make the shadow work too! I´m trying for some time but didn´t make it work. It moves away from the MC too far.

abgen
July 24th, 2006, 11:38 AM
You need to simply create another movieclip of the same size and shape (i.e. duplicate) of the original. Then do:

clip1.shadow = mcShadow // mcShadow is the name of the shadow mov clip

and it needs to have the same registration / anchor point as the clip1

felipegm
July 24th, 2006, 11:58 AM
You need to simply create another movieclip of the same size and shape (i.e. duplicate) of the original. Then do:

clip1.shadow = mcShadow // mcShadow is the name of the shadow mov clip

and it needs to have the same registration / anchor point as the clip1

thanks a lot for the help! Really appreciate that.

it´s working almost perfectly. Since I´m doing this SWF with 2 MCs to drag, the shadow of the one that is being dragged, does not get over the other MC. It goes below it. How do i fix that?

bighero
July 31st, 2006, 02:29 PM
Thanks alot for the wave script. I'm still new to the as drawig stuff. How can I customize the wave to make its power a little weaker. Currently, It could be a tsunami if i move the mouse from the bottom to the top. Just want to make it as dripple in lake :D Please help me in this situation. Thanks in advance!

abgen
July 31st, 2006, 06:18 PM
thanks a lot for the help! Really appreciate that.

it´s working almost perfectly. Since I´m doing this SWF with 2 MCs to drag, the shadow of the one that is being dragged, does not get over the other MC. It goes below it. How do i fix that?

For that, my man you need to swapDepths. Check in the code for the onPress function.

You need to put a line above where it says:

this.swapDepths(this._parent.getNextHighestDepth() );

which says:

if(this.shadow) this.shadow.swapDepths(this._parent.getNextHighest Depth());

This will position the shadow at the top, and then the 'old' line will plop the clip above the shadow. Happy Days™

abgen
July 31st, 2006, 06:20 PM
Thanks alot for the wave script. I'm still new to the as drawig stuff. How can I customize the wave to make its power a little weaker. Currently, It could be a tsunami if i move the mouse from the bottom to the top. Just want to make it as dripple in lake :D Please help me in this situation. Thanks in advance!

I do believe you want to change the mass of the particles and the strength of the Springs for that, there. In such cases you want to look at the fK value at the top, and the mListener object which tracks the mouse pos. It's not perfect but in general it tracks the mouse to determine what kind of acceleration is given to the particles. There's five lines in the mListener code which you need to look at where it finds the nearest particle and the two either side. The number after the divisions (I forget what they are) - whack those up a bit.

Paul

woodman650
August 3rd, 2006, 03:34 PM
any word on the collision detection for the AS wave? I think this is the coolest thing I've seen for flash (pertaining to my interests). thanks for the great post Paul!

abgen
August 3rd, 2006, 07:06 PM
any word on the collision detection for the AS wave? I think this is the coolest thing I've seen for flash (pertaining to my interests). thanks for the great post Paul!

Not as yet :)

I've been a bit snowed under of late, and suffering from a slight lack of motivation. Will do it as soon as I can!

Paul

GPP
August 3rd, 2006, 11:14 PM
Good job! :thumb: but the wave would look a bit more realistic if water flew out of it too

abgen
August 4th, 2006, 06:54 AM
Good job! :thumb: but the wave would look a bit more realistic if water flew out of it too

Right, smartypants, I'll let YOU model that one :P;)

cfflash
August 4th, 2006, 05:09 PM
Paul,

I've been wanting to reach this level of experimentation, but how exactly does one start? How did you come up with the formulas? If I wanted to create my own version, for learning purposes obviously, where do I start?

What did the first version of this look like?

For me, I see the end result and get disgruntled because it's hard to picture myself creating something like this.

Need advice!

tolk
August 8th, 2006, 07:41 AM
Very very similar to this (http://www.senocular.com/flash/source.php?id=0.28)

Nicely presented and well done though.