PDA

View Full Version : wind simulation



radiocg
March 4th, 2005, 08:01 PM
Hi everyone,

I have a question. I have this website i am making which you can see here

Click here to see (http://www.radiocg.com/heyholmes/main.htm)

At the bottom I have some leaves there. I want to make a couple different size leaves like that and make them go from left to right at random paths and have it loop. I dont know much about actionscript but is there a way to do this withough havingto make a bunch of guide paths and doing lots of tweens and rotations? Thanks for the help

stringy
March 5th, 2005, 05:07 AM
Hi everyone,

I have a question. I have this website i am making which you can see here

Click here to see (http://www.radiocg.com/heyholmes/main.htm)

At the bottom I have some leaves there. I want to make a couple different size leaves like that and make them go from left to right at random paths and have it loop. I dont know much about actionscript but is there a way to do this withough havingto make a bunch of guide paths and doing lots of tweens and rotations? Thanks for the help


you might be able to use something from this, just have a play around with the speed variables etc.

radiocg
March 5th, 2005, 04:16 PM
awesome, thanks alot dude i will post my results

radiocg
March 5th, 2005, 04:29 PM
Which variables in there do i need to adjust for velocity and how many are on the screen and rotation?

stringy
March 5th, 2005, 06:42 PM
Which variables in there do i need to adjust for velocity and how many are on the screen and rotation?
horizintal- clip.velX
vertical- clip.velY
how many- for (var i = 1; i<20; i++) { -change the 20
rotation- clip.rot

radiocg
March 7th, 2005, 11:05 AM
Is there any way to make the leaves go from left to right. i am attaching the .fla file. Also i have another question for you since you were able to figure the leaves out. I was interested in putting like some grass and having it kinda move in the wind. Is there anyway to do this. I am posting a picture. Thanks for your help.

Click here for .fla (http://www.indesignmedia.com/main.fla)

http://www.indesignmedia.com/interface.jpg

ANEWIDEACo
March 7th, 2005, 01:28 PM
Have you tried the grass tutorial?

In like flash mx or action script.

stringy
March 7th, 2005, 01:57 PM
Is there any way to make the leaves go from left to right. i am attaching the .fla file. Also i have another question for you since you were able to figure the leaves out. I was interested in putting like some grass and having it kinda move in the wind. Is there anyway to do this. I am posting a picture. Thanks for your help.

Click here for .fla (http://www.indesignmedia.com/main.fla)

http://www.indesignmedia.com/interface.jpg

try Anewideaco`s suggestion for grass. I can`t open your file,using mx but to change direction just swap all xVel values to positive
myArray = [];
createEmptyMovieClip("box", 1);
box.setMask(mask);
function myfunction(x, y) {
x[1]>y[1] ? k=1 : y[1]>x[1] ? k=-1 : k=0;
return k;
}
function initleaf() {
for (var i = 1; i<20; i++) {
clip = box.attachMovie("leaf", "l"+i, i);
clip._y = 400+random(50);
clip._x = Math.random()*800;
clip._rotation = random(180);
clip.rot = Math.random()-.5;
clip.amount = Math.random()*2;
clip.velX = (.5+Math.round(Math.random()));
clip.velY = Math.random()*.3-.1;
clip._xscale = clip._yscale=50+random(100);
myArray.push([clip, clip._yscale]);
clip.onEnterFrame = move;
clip.amount = Math.random()*2;
}
myArray.sort(myfunction);
myinterval = setInterval(depthswapper, 200);
}
function depthswapper() {
clearInterval(myinterval);
for (var j = 0; j<myArray.length; j++) {
myArray[j][0].swapDepths(j+50);
}
}
function wind() {
for (var obj in myArray) {
myArray[obj][0].velX = (.5+Math.round(Math.random()));
}
}
winterval = setInterval(wind, 5000);
function move() {
this._x += this.velX;
this._y += this.velY;
this._rotation += this.rot;
this._yscale -= this.amount;
if (Math.abs(this._yscale)>=100) {
this.amount *= -1;
}
if (this._x>Stage.width) {
this._x = 0;
this._y = 400+random(50);
}
}
initleaf();

radiocg
March 7th, 2005, 05:50 PM
Thanks Stringy. Here is the flash file again with the grass in MX format.

Click here for file (http://www.radiocg.com/mainmx.fla)

stringy
March 8th, 2005, 01:18 AM
Thanks Stringy. Here is the flash file again with the grass in MX format.

Click here for file (http://www.radiocg.com/mainmx.fla)
Because you only have a couple of blades of grass i think you will get better results by breaking apart and making each blade a mc on its own time line and just tweening.Not worth duplicating unless you are creating a whole meadow.

radiocg
March 8th, 2005, 02:10 AM
yea i am making an entire meadow

radiocg
March 8th, 2005, 02:12 AM
is there anyway to duplicate the blades quickly?

stringy
March 8th, 2005, 10:52 AM
is there anyway to duplicate the blades quickly?
yes,just use attachMovie, the same as the leafs
Done this quickly, maybe some help but i still think you might be better tweening the mcs on their timelines,then duplicating and getting them to play at different frames.http://www.fmx6.com/teststuff/mainmx.fla

radiocg
March 8th, 2005, 10:59 AM
thanks for your help stringy. I appreciate it.

stringy
March 8th, 2005, 11:14 AM
thanks for your help stringy. I appreciate it.
you are welcome