How To Make Rain Effect In Adobe Flash With Action Script 2.0

Views:
Friends, Now i share a simple trick to get rain fall effect to your animation with AS 2.0. It is very simple to use in  your own flash animation. For that you first need any software that with action script 2.0. Now i share this tutorial with Adobe Flash CS6. This is a nice 2D animation Software that  you can easily make any 2D animation, even you are not perfect in drawing. In my view you can also make this similar rain effect with tweens. But that is time wasting process. So that i share this script based tutorial to all. First of all you should follow below instruction to make success.

LIVE DEMO









First open Adobe Flash with Action Script 2.0.


  • Draw an object.

  • Convert it to a MovieClip Symbol  . 

  • Select object  then click F8 . Now appear a window like below.  Select MovieClip option. 



  • Then click on Advanced option. Then select "Export for ActionScript".



  • Then Click on first frame on timeline. Press F9.

  • Now appear ActionScript  window.


  • Now copy and paste below code into that window.

//Creating an empty movieclip to attach the clip from library
_root.createEmptyMovieClip("holder",this.getNextHighestDepth());
//settig variables
holder.maxdrops=30;//no of drops
var downspeed=15;//speed of the drops
var dropslop=10;//slop of the drops
//Part 1 attaching the clips with loop
for(i=0;i<holder.maxdrops;i++){
holder.attachMovie("rain","drop"+i,i+5);
focuseddrop=holder["drop"+i]
focuseddrop.cacheAsBitmap=true;
focuseddrop._x=random(Stage.width);
focuseddrop._y=random(Stage.height);
focuseddrop._yscale=random(100);
focuseddrop._rotation=-dropslop;
}
//part 2 setting an interval for motion of drops
var dropup=setInterval(movedrop,1)
//function to repeat in the interval
function movedrop(){
for(i=0;i<holder.maxdrops;i++){
focuseddrop=holder["drop"+i]
focuseddrop._rotation=-dropslop;
focuseddrop._y+=25+downspeed/focuseddrop._yscale;
focuseddrop.x+=Math.tan(dropslop);
if(focuseddrop._y>=Stage.height+20){
focuseddrop._y=random(30);
focuseddrop._x=random(Stage.width);
}
}
}


Change highlighted RED color with your MovieClip name. And you can also adjust Speed, Drop amount, Height and Angle or Slop bye adjusting highlighted GREEN color


  • Paste script  in ActionScript window like below.


  • Press CTRL+Enter to view animation.

  • Thats all.






If you like this tutorial follow me.




How To Make Rain Effect In Adobe Flash With Action Script 2.0 How To Make Rain Effect In Adobe Flash With Action Script 2.0 Reviewed by Gaint Hackers on 05:50 Rating: 5

No comments:

Powered by Blogger.