当前位置:软件学习 > Flash >>

flash9复制效果《二》水泡

H2O类:

//********************************************************//
//*******本类由浪子啸天创意设计****************************//
//*******有什么问题请mail:webmaster@flasc.cn******************//
//*******更多的请访问:http://www.flasc.cn***//
//*******转载请注明处处,请保留版权*************************//
//*******************************************************//

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;
  }
 }
}

 

flash9内代码:

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();

补充:flash教程,As3.0
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,