-
[RESOLVED] Rising rain
Hello, can anyone help me modify the following code (the code to make it rain), so instead of the movieclip duplicating and falling, it duplicates and rises...
This code is in the movieclip:
onClipEvent (load) {
//put the size of the movie stage here
movieWidth = 550;
movieHeight = 300;
//variables that will modify the falling snow
//this is for the speed of the falling rain
i = 20+Math.random()*100;
k = -Math.PI+Math.random()*Math.PI;
//giving each snowflake unique characteristics
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 75+Math.random()*100;
this._x = -10+Math.random()*movieWidth;
this._y = -10+Math.random()*movieHeight;
}
onClipEvent (enterFrame) {
//putting it all together
rad += (k/180)*Math.PI;
this._x -= Math.cos(rad);
this._y += i;
if (this._y>=movieHeight) {
this._y = -5;
}
if ((this._x>=movieWidth) || (this._x<=0)) {
this._x = -10+Math.random()*movieWidth;
this._y = -5;
}
}
This code is in the frame:
for (k=0; k<25; k++) {
duplicateMovieClip(_root.rain, "rain"+k, k);
}
Also, I can see this wont work if you import the .swf into anther movie, does anyone know why?
Thanks in advance..
Steve
-
change _root to _parent to fix the loading problem.
change
this._y += i;
if (this._y>=movieHeight) {
this._y = -5;
to
this._y -= i;
if (this._y<=movieHeight) {
this._y = movieHeight+5;
that might do it.
-
Aha!!! Fantastic, thankyou Bret :) The rising rain didn't work at first, everything was stuck below the movie,so I fiddled around with it (since you told me where to look). For anyone interested, here's how to reverse the effect... (only a tiny bit different to the above amendments)..
this._y -= i;
if (this._y>=movieHeight) {
this._y = movieHeight+5;
Thanks again Bret
Steve
-
Actually, Ive been messing round with it more now because it only plays the rising rain for about a second.. I've modified almost every part without success, any idea what Im doing wrong???
-
1 Attachment(s)
If you try the original while exporting in flash 5 it should work. This was an old script from several years ago that was played around on in this forum.
-
Brilliant, cheers mate. One more problem though, I need it to work inside another movie... Im using it as a background, however, it won't work inside the other movie.. it just displays one rising rain drop. Ive tried changing the _root to parent, but this isnt working... Ive tried chaging the root movie export settings but still nothing... any ideas why it's being difficult?
Cheers
Steve
-
http://www.diversioncentral.com/thesween/bubble2.html
if this works the the fun file is at
http://www.diversioncentral.com/thesween/bubble2.fun
let me know if it works becuase it took a while to get it to reproduce and I will not say thats its right to begin with. But it shoiuld work with flash 8. If it does then I can put it on koolexchange.
-
FANTASTIC MATE!!! The bubbles are awesome and also work inside another movie perfectly!!! I love the added feature of the bubble moving away from the curser slightly, nice touch.. Top effect! Definetly add that to kool exchange.
Thanks again for the help
Steve
-
I changed this and uploaded to koolexchange. It now has floating links effect which has been done before but still something different.
http://www.diversioncentral.com/thesween/bubble2.html
-
Awesome mate, looks great... People will definetly be greatful for this one.
Nice1
Steve