注册时间2021-7-7
在线时间 小时
- 最后登录
- 1970-1-1
|
- package
- {
- import flash.display.Sprite;
- import flash.utils.Timer;
- import flash.events.TimerEvent;
-
- public class RainAndRipples extends Sprite
- {
- var thisW:Number;
- var thisH:Number;
- var timer:Timer;
- var rain;
- Rain;
- public function RainAndRipples(w:Number=550,h:Number=400)
- {
- rain = new Rain(w,h);
- addChild(rain);
- timer = new Timer(30);
- timer.addEventListener(TimerEvent.TIMER,timerHandler);
- timer.start();
- }
-
- function timerHandler(e:TimerEvent):void
- {
- rain.frame();
- }
-
-
-
-
- }
-
- }
-
- import flash.display.Sprite;
- import flash.utils.Timer;
- import flash.events.Event
-
- class Rain extends Sprite
- {
-
- var thisW:Number;
- var thisH:Number;
- var rainX:Number;
- var rainY:Number;
- public function Rain(w:Number=550,h:Number=400):void
- {
- thisW = w;
- thisH = h;
- }
-
- public function frame():void
- {
- var mc:Sprite=new Sprite();
- mc.graphics.beginFill(0xbbffff,0.8);
- mc.graphics.drawEllipse(-0.5,-2,1,4);
- addChild(mc);
- mc.scaleX = mc.scaleY = 0.7 + 0.3 * Math.random();
- rainX = mc.x = 50 + Math.random() * thisW;
- mc.y = -20 - 20 * Math.random();
- rainY = thisH/2 + Math.random() * (thisH/2);
- mc.addEventListener(Event.ENTER_FRAME,frameB);
- function frameB(e)
- {
- if (mc.y < rainY)
- {
- mc.y +=6;
- }
- else
- {
- mc.removeEventListener(Event.ENTER_FRAME,frameB);
- removeChild(mc);
- mc = null;
- }
- }
- init(rainX,rainY);
- }
-
- function init(x1:Number,y1:Number)
- {
- var mc:Sprite=new Sprite();
- addChild(mc);
- mc.x = x1;
- mc.y = y1;
- mc.graphics.lineStyle(0.5,0xbbffff,0.6);
- mc.graphics.drawEllipse(-1,-0.3,2,0.6);
- var v0 = 0.5 + 0.3 * Math.random();
- mc.addEventListener(Event.ENTER_FRAME,frame);
-
- function frame(e)
- {
- mc.scaleX = mc.scaleY += v0;
- mc.alpha > 0 ? mc.alpha -= 0.02:[mc.removeEventListener(Event.ENTER_FRAME,frame),removeChild(mc),mc = null];
- }
- }
-
- }
- 调用代码
- var rain:RainAndRipples=new RainAndRipples(550,400)//550,400分别是雨的范围
- addChild(rain)
复制代码 |
评分
-
查看全部评分
|