我是一名Web設計專業的學生,他在課堂上輕輕觸碰Actionscript,我的作業有些問題。這個任務是使用一個符號創建10個氣球,並使它們以不同的速度上升到屏幕的頂部,並停止僅使用AS(無時間軸動畫的東西)。Beginner Actionscript/Flash - 一個符號的多個實例,速度
我想我幾乎擁有它,但我不確定爲什麼我不能改變每個氣球的速度。他們都一起興起。有什麼我不正確的做法?
import flash.display.MovieClip;
import flash.events.Event;
var Cball:MovieClip = new rainbow();
Cball.x = 400;
Cball.y = 575;
addChild(Cball);
var Cball1:MovieClip = new rainbow();
Cball1.x = 200;
Cball1.y = 575;
addChild(Cball1);
var Cball2:MovieClip = new rainbow();
Cball2.x = 385;
Cball2.y = 575;
addChild(Cball2);
var Cball3:MovieClip = new rainbow();
Cball3.x = 500;
Cball3.y = 575;
addChild(Cball3);
var Cball4:MovieClip = new rainbow();
Cball4.x = 600;
Cball4.y = 575;
addChild(Cball4);
var Cball5:MovieClip = new rainbow();
Cball5.x = 405;
Cball5.y = 575;
addChild(Cball5);
var Cball6:MovieClip = new rainbow();
Cball6.x = 333;
Cball6.y = 575;
addChild(Cball6);
var Cball7:MovieClip = new rainbow();
Cball7.x = 250;
Cball7.y = 575;
addChild(Cball7);
var Cball8:MovieClip = new rainbow();
Cball8.x = 100;
Cball8.y = 575;
addChild(Cball8);
var Cball9:MovieClip = new rainbow();
Cball9.x = 700;
Cball9.y = 575;
addChild(Cball9);
var xVel:Number = 0;
var yVel:Number = -5;
addEventListener(Event.ENTER_FRAME, onLoop, false, 0, true);
function onLoop(evt:Event):void {
// THis is for balloon number A ********************
Cball.x += xVel;
Cball.y += yVel;
// Check for collisions on every frame
if (Cball.y >= 575) {
yVel = -5;
}// end if
if (Cball.y <= 25) {
yVel = 0;
} // end if
// End of balloon number A script ******************
// THis is for balloon number 1 ********************
Cball1.x += xVel;
Cball1.y += yVel;
// Check for collisions on every frame
if (Cball1.y >= 575) {
yVel = -5;
}// end if
if (Cball1.y <= 25) {
yVel = 0;
} // end if
// End of balloon number 1 script ******************
// THis is for balloon number 2 ********************
Cball2.x += xVel;
Cball2.y += yVel;
// Check for collisions on every frame
if (Cball2.y >= 550) {
yVel = -5;
}// end if
if (Cball2.y <= 25) {
yVel = 0;
} // end if
// End of balloon number 2 script ******************
// THis is for balloon number 3 ********************
Cball3.x += xVel;
Cball3.y += yVel;
// Check for collisions on every frame
if (Cball3.y >= 550) {
yVel = -5;
}// end if
if (Cball3.y <= 25) {
yVel = 0;
} // end if
// End of balloon number 3 script ******************
// THis is for balloon number 4 ********************
Cball4.x += xVel;
Cball4.y += yVel;
// Check for collisions on every frame
if (Cball4.y >= 550) {
yVel = -5;
}// end if
if (Cball4.y <= 25) {
yVel = 0;
} // end if
// End of balloon number 4 script ******************
// THis is for balloon number 5 ********************
Cball5.x += xVel;
Cball5.y += yVel;
// Check for collisions on every frame
if (Cball5.y >= 550) {
yVel = -5;
}// end if
if (Cball5.y <= 25) {
yVel = 0;
} // end if
// End of balloon number 5 script ******************
// THis is for balloon number 6 ********************
Cball6.x += xVel;
Cball6.y += yVel;
// Check for collisions on every frame
if (Cball6.y >= 550) {
yVel = -5;
}// end if
if (Cball6.y <= 25) {
yVel = 0;
} // end if
// End of balloon number 6 script ******************
// THis is for balloon number 7 ********************
Cball7.x += xVel;
Cball7.y += yVel;
// Check for collisions on every frame
if (Cball7.y >= 550) {
yVel = -5;
}// end if
if (Cball7.y <= 25) {
yVel = 0;
} // end if
// End of balloon number 7 script ******************
// THis is for balloon number 8 ********************
Cball8.x += xVel;
Cball8.y += yVel;
// Check for collisions on every frame
if (Cball8.y >= 550) {
yVel = -5;
}// end if
if (Cball8.y <= 25) {
yVel = 0;
} // end if
// End of balloon number 8 script ******************
// THis is for balloon number 9 ********************
Cball9.x += xVel;
Cball9.y += yVel;
// Check for collisions on every frame
if (Cball9.y >= 550) {
yVel = -5;
}// end if
if (Cball9.y <= 25) {
yVel = 0;
} // end if
// End of balloon number 9 script ******************
} // end onloop function