写as3注释请为我下面的代码写注释 var i:int=0;var a:Array=new Array(0x33ccff,0xff0000,0x00ff00,0xff99ff);addEventListener(Event.ENTER_FRAME,f);function f(e:Event):void {var index:int=int(Math.random()*5);drawF(Math.random()*12+40,a[index]

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 01:57:08
写as3注释请为我下面的代码写注释vari:int=0;vara:Array=newArray(0x33ccff,0xff0000,0x00ff00,0xff99ff);addEventListene

写as3注释请为我下面的代码写注释 var i:int=0;var a:Array=new Array(0x33ccff,0xff0000,0x00ff00,0xff99ff);addEventListener(Event.ENTER_FRAME,f);function f(e:Event):void {var index:int=int(Math.random()*5);drawF(Math.random()*12+40,a[index]
写as3注释
请为我下面的代码写注释
var i:int=0;
var a:Array=new Array(0x33ccff,0xff0000,0x00ff00,0xff99ff);
addEventListener(Event.ENTER_FRAME,f);
function f(e:Event):void {
var index:int=int(Math.random()*5);
drawF(Math.random()*12+40,a[index]);
i++;
if (i==20) {
removeEventListener(Event.ENTER_FRAME,f);
}
}
function drawF(w:Number,color:Number):void {
var mc:MovieClip=new MovieClip();
mc.graphics.lineStyle();
mc.graphics.beginGradientFill(GradientType.RADIAL,[0xffffff,color],[1,1],[10,120]);
var h:Number=w*1.2;
mc.graphics.drawEllipse(-15,-15,w,h);
mc.graphics.endFill();
mc.graphics.moveTo(w/2-15,h-15);
mc.graphics.lineStyle(1);
mc.graphics.curveTo(w/2-15,1.5*h-15,0-15,2*h-15);
addChild(mc);
mc.x=Math.random()*550;
mc.y=400+400*Math.random();
mc.vx=Math.random()*4-2;
mc.vy=Math.random()*2+2;
mc.addEventListener(Event.ENTER_FRAME,enterF);
}
function enterF(e:Event):void {
var mc0:MovieClip=e.target as MovieClip;
if (Math.random()500+mc0.width) {
mc0.vx=2;
mc0.x=-mc0.width;
}
if (mc0.y

写as3注释请为我下面的代码写注释 var i:int=0;var a:Array=new Array(0x33ccff,0xff0000,0x00ff00,0xff99ff);addEventListener(Event.ENTER_FRAME,f);function f(e:Event):void {var index:int=int(Math.random()*5);drawF(Math.random()*12+40,a[index]
var i:int=0;
var a:Array=new Array(0x33ccff,0xff0000,0x00ff00,0xff99ff);
addEventListener(Event.ENTER_FRAME,f);
function f(e:Event):void //名字为f的方法
{
var index:int=int(Math.random()*5); //定义一个int型整数变量并赋值为一个0-5的整数
drawF(Math.random()*12+40,a[index]);//调用drawf方法
i++; //i自身加一
if (i==20)
{
removeEventListener(Event.ENTER_FRAME,f);//如果当i 等于20的时候移除enter_frame 监听
}
}
function drawF(w:Number,color:Number):void //定义一个 drawf 方法
{
var mc:MovieClip=new MovieClip(); 申请并构造一个mc 的饮片剪辑
mc.graphics.lineStyle(); //申请画笔
mc.graphics.beginGradientFill(GradientType.RADIAL,[0xffffff,color],[1,1],[10,120]); //从1,1 的位置绘制一个10宽 120高的白色矩形
var h:Number=w*1.2; //申请并构造h
mc.graphics.drawEllipse(-15,-15,w,h); //画一个椭圆
mc.graphics.endFill(); //结束绘制
mc.graphics.drawEllipse(w/2-15,h-15); //绘制一个由边框(该边框由一对坐标、高度和宽度指定)定义的椭圆.
mc.graphics.lineStyle(1); //设定为直线
mc.graphics.curveTo(w/2-15,1.5*h-15,0-15,2*h-15); //绘制曲线
addChild(mc); //将mc影片剪辑添加到场景
mc.x=Math.random()*550; //mc的x坐标随机在 0-550 之间
mc.y=400+400*Math.random(); //mc的y随即在400 - 800 之间
mc.vx=Math.random()*4-2; //mc的vx 随机在 2- 6 之间
mc.vy=Math.random()*2+2; //mc的vy 随即在 2 - 4 之间
mc.addEventListener(Event.ENTER_FRAME,enterF); //给mc添加一个ENTER_FRAME监听
}
function enterF(e:Event):void //定义一个无返回值的 enterf 方法
{
var mc0:MovieClip=e.target as MovieClip; //申请并构造mc0 的影片剪辑
if (Math.random()