
flash一段as2.0代码转成as3.0的要怎么写啊
varsceneWidth=1920;varsceneHeight=1080;varstarNum=1000;varstarSpeed=50;varstarTime=10...
var sceneWidth = 1920;
var sceneHeight = 1080;
var starNum = 1000;
var starSpeed = 50;
var starTime = 100;
var starDistance = true;
this.starMc._visible = 0;
for (var i = 0; i<starNum; i++) {
mc = this.starMc.duplicateMovieClip("startMc"+i, i+999);
mc.gotoAndPlay(random(mc._totalframes+1));
mc._x = random(sceneWidth);
mc._y = random(sceneHeight);
mc._xscale = mc._yscale=mc._alpha=random(50)+50;
mc._rotation = random(360);
mc.onEnterFrame = function() {
if (starDistance == true) {
if (this._x>0) {
this._x -= starSpeed/this._xscale;
} else {
this._x = sceneWidth;
}
} else {
if (this._x<sceneWidth) {
this._x += starSpeed/this._xscale;
} else {
this._x = 0;
}
}
}
} 展开
var sceneHeight = 1080;
var starNum = 1000;
var starSpeed = 50;
var starTime = 100;
var starDistance = true;
this.starMc._visible = 0;
for (var i = 0; i<starNum; i++) {
mc = this.starMc.duplicateMovieClip("startMc"+i, i+999);
mc.gotoAndPlay(random(mc._totalframes+1));
mc._x = random(sceneWidth);
mc._y = random(sceneHeight);
mc._xscale = mc._yscale=mc._alpha=random(50)+50;
mc._rotation = random(360);
mc.onEnterFrame = function() {
if (starDistance == true) {
if (this._x>0) {
this._x -= starSpeed/this._xscale;
} else {
this._x = sceneWidth;
}
} else {
if (this._x<sceneWidth) {
this._x += starSpeed/this._xscale;
} else {
this._x = 0;
}
}
}
} 展开
2个回答
展开全部
你需要改动一下,将库中的元件的类名称(链接属性)写上,然后才能修改脚本,而且必须保存为AS3.0的才可以修改脚本。不过你的分太少了,增加分吧。
2012-05-18
展开全部
应该主要是这段。。其他的属性只要把前面的_去掉就可以
for (var i = 0; i<starNum; i++) {
mc = this.starMc.duplicateMovieClip("startMc"+i, i+999);//var mc=new startMc();//这个startMc应该为库里该元件的链接名称
mc.gotoAndPlay(random(mc._totalframes+1));//mc.gotoAndPlay(random(mc._totalframes+1));
mc._x = random(sceneWidth);//改为x,random要用Math.random()*sceneWidth
mc._y = random(sceneHeight);//改为y,random同上
mc._xscale = mc._yscale=mc._alpha=random(50)+50;//改属性写法和random
mc._rotation = random(360);
mc.onEnterFrame = function() {//此处函数不可这么写。应该用侦听。。mc.addEventListener(Event.ENTER_FRAME,enterFrame),把下面的函数放在enterFrame里面。。}
}
function enterFrame(e:Event){
if (starDistance == true) {
if (this._x>0) {//this改为e.target
this._x -= starSpeed/this._xscale;
} else {
this._x = sceneWidth;
}
} else {
if (this._x<sceneWidth) {
this._x += starSpeed/this._xscale;
} else {
this._x = 0;
}
}
}
主要是这么几点。
for (var i = 0; i<starNum; i++) {
mc = this.starMc.duplicateMovieClip("startMc"+i, i+999);//var mc=new startMc();//这个startMc应该为库里该元件的链接名称
mc.gotoAndPlay(random(mc._totalframes+1));//mc.gotoAndPlay(random(mc._totalframes+1));
mc._x = random(sceneWidth);//改为x,random要用Math.random()*sceneWidth
mc._y = random(sceneHeight);//改为y,random同上
mc._xscale = mc._yscale=mc._alpha=random(50)+50;//改属性写法和random
mc._rotation = random(360);
mc.onEnterFrame = function() {//此处函数不可这么写。应该用侦听。。mc.addEventListener(Event.ENTER_FRAME,enterFrame),把下面的函数放在enterFrame里面。。}
}
function enterFrame(e:Event){
if (starDistance == true) {
if (this._x>0) {//this改为e.target
this._x -= starSpeed/this._xscale;
} else {
this._x = sceneWidth;
}
} else {
if (this._x<sceneWidth) {
this._x += starSpeed/this._xscale;
} else {
this._x = 0;
}
}
}
主要是这么几点。
追问
还是不行啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询