Falling Leaves
i'm trying to make a movie with leaves falling from the sky, i did look at the movies on this site and non of them fit what i want or we're buggy.
can someone help me with a sample fla that makes movie clips fall at random _x values within a range i can set and follow along a sine wave path with dynamic settings as well.
thanks!
May be something like this?
Attached Files
wow that is pretty ****ing amazing. any chance you can comment the code for me so i can know how to change the max _x area to allow the leaves to fall. also is there a way to set the interval the leaves fall at (the amount of leaves that can be on stage at once) and the speed in which they fall?
thank you so much for this! you rule.
My English is not good enough, but I hope it'll help.
code: fall = function (target, weather) {
// target - where the leaves are falling. weather - frequency (msec)
target.weather = weather;
//right bottom corner of the stage
target.br = {x:Stage.width-target._x, y:Stage.height-target._y};
// array of the leaves
target.lfs = [];
target.fallLf = function(index) {
if (index == undefined) {
var index = this.lfs.length;
} else {
clearInterval(this.lfs[index]);
}
var neo = this.createEmptyMovieClip("leaf"+index, index);
neo.attachMovie("leaf", "core", 3);
neo.idx = index;
neo._y = -30; //_y coordinate where the leaves appear
neo.core._xscale = 100-random(3)*10;
neo.core._yscale = neo.core._xscale;
neo._rotation = random(150);
neo.dx = random(this.br.x);
neo._x = neo.dx;
neo.amp = {x 1+random(25))*10}; //Amplitude _x
neo.amp.scale = Math.PI/2*(1+random(3));
neo.onEnterFrame = function() {
if (this._y-3<430) { //Bottom line where the leaves disappear
var ph = this._y/this._parent.br.y*this.amp.scale;
var cs = Math.cos(ph);
this.core._xscale = 30+Math.abs(70*cs);
this._x = this.dx+this.amp.x*cs;
this._y += 3; //Speed of fall. Try to change this value
} else {
clearInterval(this._parent.id);
var id = setInterval(this._parent, "fallLf", this._parent.weather, this.idx);
this._parent.lfs.splice(this.idx, 1, id);
removeMovieClip(this);
}
};
this.lfs.splice(index, 1, neo);
return neo;
};
target.fallLf();
target.id = setInterval(target, "fallLf", weather);
};
fall(this, 500); //Try to change this frequency to change amount the leaves on a stage
rad, i see where you set the _y values for the leaves, but i'm not sure where the _x stage range is. like say i only want leaves to fall on a 500px stage, _x= 0 to _x= 400.
thanks alot!
OK, I understand. Then you should use number 400 instead of Stage.width. (Third line of the code from top). You can change Stage.height also.
I've redone it from my old fla., so you may correct it for your needs.
i tried to change it to say 100 like this:
target.br = {x:100-target._x, y:Stage.height-target._y};
and it was still spawning leaves that we're at least at 350 _x from the top left corner or the stage, so it doens't seem to work for me?
OK, try this variant. I've corrected it a little bit.
Attached Files
yay thats totally sweet thanks alot. it would be cool to make one of those that makes it snow. would that be hard to do? the snowfall could be sized at a random _x and _y scale, like what you have going on sort of.
again thanks alot this was imprtant for me !
It's not too hard to do. Take a look at this
Attached Files
holy crap thanks alot your awesome!
in the snow file, is there a way to get the spawned flake in the upper left hand corner to disappear? it messes up the design
May be it's not the best design but it's made with ActionScript only.
Attached Files
holy **** that's impressive! what i'm talking about though is if you look in the top left corner, there is a snowflake just sitting there, i assume it was the first one created on stage. is there a way to get rid of it?
here is my updated code:
_quality="medium";
depth =0;
this.createEmptyMovieClip("StarSky", ++depth)
with (StarSky) {
// do nothing
}
for(i=1; i<150; i++) {
duplicateMovieClip(StarSky.Star0,"Star"+i, ++depth)
StarSky["Star"+i]._yscale = 20
StarSky["Star"+i]._alpha = 100-random(50)
StarSky["Star"+i]._x = random(270)
StarSky["Star"+i]._y = random(300-150)
}
StarSky.Star1._x=StarSky.Star0._x;
StarSky.Star1._y=StarSky.Star0._y;
StarSky.Star1._xscale=270;
StarSky.Star0.onEnterFrame = function(){
with (StarSky.Star0){
if (!flag) {
_root.StarSky.Star1._alpha=_alpha-=10
if(_alpha<0) {flag=true; _root.StarSky.Star1._x=(_x = random(270/2)); _root.StarSky.Star1._y=10+(_y = random((300)/3))}
}else{
_root.StarSky.Star1._alpha=_alpha+=10
if (_alpha>100) {flag = false}
}
}}
// amount ofd snow on screen
snum = 25;
createSnow = function () {
_root.createEmptyMovieClip('snow0', ++depth);
with (_root.snow0) {
beginFill(0xF0F0FF, 100);
moveTo(4, 0);
lineTo(3, 3);
lineTo(0, 4);
lineTo(3, 5);
lineTo(4, 8);
lineTo(5, 5);
lineTo(8, 4);
lineTo(5, 3);
lineTo(4, 0);
endFill;
beginFill(0xFFFFFF, 100);
moveTo(4, 3);
lineTo(1, 1);
lineTo(3, 4);
lineTo(1, 7);
lineTo(4, 5);
lineTo(7, 7);
lineTo(5, 4);
lineTo(7, 1);
lineTo(4, 3);
endFill;
_visible=false;
};
for (i=0; i<snum; i++) {
_root.snow0.duplicateMovieClip('snow'+i, ++depth);
_root['snow'+i].angle = random(361);
_root['snow'+i]._x = random(270)+1;
_root['snow'+i]._y = random(300)+1;
_root['snow'+i]._alpha = random(60)+40;
_root['snow'+i]._xscale=random(70)+30;
_root['snow'+i]._yscale=random(70)+30;
_root['snow'+i].speed = random(3)+1;
_root['snow'+i].onEnterFrame = function() {
if (++this.angle>360) {
this.angle -= 360;
}
this._y += 0.5*this.speed;
this._x += Math.cos(this.angle*Math.PI/180)*this.speed/2;
if (this._y>400) {
this._y = -10;
}
};
}
};
createSnow();
Oh, yes, I see… We can just move it a little bit aside.
createSnow = function () {
_root.createEmptyMovieClip('snow0', ++depth);
with (_root.snow0) {
beginFill(0xFFFFFF, 40);
moveTo(4, 0);
lineTo(3, 3);
lineTo(0, 4);
lineTo(3, 5);
lineTo(4, 8);
lineTo(5, 5);
lineTo(8, 4);
lineTo(5, 3);
lineTo(4, 0);
endFill;
beginFill(0xFFFFFF, 40);
moveTo(4, 3);
lineTo(1, 1);
lineTo(3, 4);
lineTo(1, 7);
lineTo(4, 5);
lineTo(7, 7);
lineTo(5, 4);
lineTo(7, 1);
lineTo(4, 3);
endFill;
};
snow0._x = -10;
snow0._y = -10;
fixed it thanks alot your awesome.
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width