as3 加入影片剪辑
类一:package{importflash.display.*;importflash.events.*;importflash.utils.getTimer;publ...
类一:
package
{
import flash.display.*;
import flash.events.*;
import flash.utils.getTimer;
public class Airplane extends MovieClip
{
var dx:Number;
var lasttime:int;
public function Airplane(side:String,dx:Number,altitude:Number)
{
if (side=="right")
{
this.scaleX = -1;
this.dx= - dx;
this.x = 600;
}
else if (side=="left")
{
this.scaleX = 1;
this.dx = dx;
this.x = -50;
}
this.y = altitude;
this.gotoAndStop(Math.floor(Math.random()*5+1));
addEventListener(Event.ENTER_FRAME,planemove);
lasttime = getTimer();
}
private function planemove(e:Event):void
{
var passtime:int = getTimer() - lasttime;
lasttime += passtime;
this.x = dx * passtime / 1000;
/*if (dx>0&&x>600)
{
deleteplane();
}
else if (dx<0&&dx<-50)
{
deleteplane();
}*/
}
}
}
类二:
package
{
import flash.display.*;
import flash.events.*;
import flash.utils.Timer;
import flash.text.TextField;
public class AirRaid extends MovieClip
{
public function AirRaid()
{
var p:Airplane = new Airplane("left",170,30);
addChild(p);
}
}
}
然后我绑定类二,但是什么都显示不出来,哪里错了? 展开
package
{
import flash.display.*;
import flash.events.*;
import flash.utils.getTimer;
public class Airplane extends MovieClip
{
var dx:Number;
var lasttime:int;
public function Airplane(side:String,dx:Number,altitude:Number)
{
if (side=="right")
{
this.scaleX = -1;
this.dx= - dx;
this.x = 600;
}
else if (side=="left")
{
this.scaleX = 1;
this.dx = dx;
this.x = -50;
}
this.y = altitude;
this.gotoAndStop(Math.floor(Math.random()*5+1));
addEventListener(Event.ENTER_FRAME,planemove);
lasttime = getTimer();
}
private function planemove(e:Event):void
{
var passtime:int = getTimer() - lasttime;
lasttime += passtime;
this.x = dx * passtime / 1000;
/*if (dx>0&&x>600)
{
deleteplane();
}
else if (dx<0&&dx<-50)
{
deleteplane();
}*/
}
}
}
类二:
package
{
import flash.display.*;
import flash.events.*;
import flash.utils.Timer;
import flash.text.TextField;
public class AirRaid extends MovieClip
{
public function AirRaid()
{
var p:Airplane = new Airplane("left",170,30);
addChild(p);
}
}
}
然后我绑定类二,但是什么都显示不出来,哪里错了? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询