Can someone help me with rain move effect image AS3?

Asked By 50 points N/A Posted on -
qa-featured

Hi guys. I'm new to Flash so please bear with me. I'm trying to add a rain moving effect on a 3D image. I need the effect behind the image. I use ActionScript 3 on a Windows XP 64 bit platform. Can someone lend or teach me a script for rain move effect image AS3?

SHARE
Answered By 0 points N/A #141067

Can someone help me with rain move effect image AS3?

qa-featured
Hi! I will help you to make an animated rain drop as your background in ActionScript 3:
 
1. First, create a new file then set the size to what you want.
 
2. You can add another image to set it as the background picture.
 
3. Add new layer then name it "raincode". Make sure to lock this layer to avoid any replacement of unwanted images.
 
4. Create your own rain drop image using the graphics and color make it white. Use a linear gradient to look better. Convert your graphic to a movieclip then name it as "raindrop" don't forget to check the checkbox of "Export for ActionScript"
 
5. Now type the code given below in other ActionScript:
 
package Classes
{
import flash.display.MovieClip;
import flash.events.Event;
 
The word "Classes" here is the name of your folder where the class can be found.
6. To be able to use the addChild () method, you need to extend the class
 
public class Rain extend MovieClip
{
 
7. You need to use the Flash Player 10 Class "Vector" then put the vector that will work like an array.
 
private var offset:int = 50;  
private var dropsNumber:int;  
private var dropsVector:Vector.<MovieClip> = new Vector.<MovieClip>();
 
8. Type the main function:
 
public function init(drops:int, fallSpeed:int, windSpeed:int, hArea:int, vArea:int, dir:String):void  
{  
  dropsNumber = drops; 
 
9. You need to make the direction of the rain where its drop:
 
if (dir == "right")  
{  
offset *= -1;  
}
 
10. Add this code in creating the new drop object using the "For statement"
 
for (var i:int = 0; i < drops; i++)  
{    
var drop:Drop = new Drop();  
  
drop.fallSpeed=fallSpeed; 
drop.windSpeed=windSpeed;  
drop.dir=dir;  
drop.hArea=hArea;  
drop.vArea=vArea;
 
11. You need to make a random position:
 
drop.x = Math.random() * (hArea + offset);  
drop.y=Math.random()*vArea;
 
12. And add this code to the scale:
 
drop.scaleX = Math.round(((Math.random() * 0.8) + 0.3) * 10) / 10;  
drop.scaleY=drop.scaleX;
 
13. You need to add a drop using this code:
 
dropsVector.push(drop);  
addChild(drop);  
  
} //End of For statement in number 20
  
inTheDirection();    
  
} //End of init function
 
 
14. Add this code for the direction of the drop vector (open the attachment name 14.txt)
15. This code is for the rain drop moves (open the attachment name 15.text)
16. In the flash IDE type this code
 
import Classes.Rain;  
  
var rain:Rain = new Rain();  
  
rain.init(200, 50, 5, 600, 300, "left");  
  
addChild(rain);
 

Login/Register to Answer

Related Questions