H2O class:
//************************************** ******************//
************************ ****//
// *** If you have any questions, mail: webmaster@flasc.cn ******************//
// *** For more information, visit: http://www.flasc.cn ***//
// ******* For reprinting, please indicate everywhere, please retain the copyright *************************//
//************************************** *****************//
Package {
Import flash. display .*;
Import flash. events .*;
Public class H2O extends MovieClip {
Var speedx = 0;
Var speedy = 0;
Public function H2O (){
Speedx =. 5 * Math. random ()-0.5;
Speedy = 5 * Math. random ();
This. addEventListener (Event. ENTER_FRAME, Mot );
}
Function Mot (e: Event ){
This. x + = speedx;
This. y-= speedy;
If (this. y <0 ){
Init ();
}
}
Function init (){
This. y = 400;
This. x = Math. random () * 550;
}
}
}
Code in Flash 9:
Function DisplayCircles ()
{
For (var I: int = 0; I <100; I ++)
{
Var h2o: H2O = new H2O ();
This. addChild (h2o );
H2o. x = Math. random () * 500;
H2o. y = Math. random () * 300 + 400;
H2o. alpha =. 2 + Math. random () *. 5;
Var scale: Number =. 3 + Math. random ();
H2o. scaleX = h2o. scaleY = scale;
}
}
DisplayCircles ();