1
A
回答
2
您可以將事件偵聽器添加到偵聽事件的顯示對象的父容器中。在每個Event.ENTER_FRAME
事件中,您只需減少顯示對象的y
屬性(如下例所示)。
package
{
import flash.display.Sprite;
import flash.events.Event;
[SWF(width="600", height="500")]
public class Main extends Sprite
{
private var _squares:Vector.<Square>;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}// end function
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
_squares = new Vector.<Square>();
var redSquare:Square = new Square(0xFF0000, 100);
redSquare.x = 0;
redSquare.y = 400;
addChild(redSquare);
var greenSquare:Square = new Square(0x00FF00, 100);
greenSquare.x = 300;
greenSquare.y = 300;
addChild(greenSquare);
var blueSquare:Square = new Square(0x0000FF, 100);
blueSquare.x = 500;
blueSquare.y = 100;
addChild(blueSquare);
_squares.push(redSquare, greenSquare, blueSquare);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}// end function
private function onEnterFrame(e:Event):void
{
for each(var square:Square in _squares)
{
if (square.y > 0) square.y -= 5;
}// end for
}// end function
}// end class
}// end package
import flash.display.Sprite;
internal class Square extends Sprite
{
public function Square(color:uint, size:Number)
{
graphics.beginFill(color);
graphics.drawRect(0, 0, size, size);
graphics.endFill();
}// end function
}// end function
我想你會開竅自己但如果你只是用GreenSock的Tweening platform代替。
0
您可以在Flash IDE中使用框架和補間動畫它們。 你也可以通過編程方式自己動畫。將每個影片剪輯放置在屏幕底部,編寫一些代碼,將您的movieClips移動到屏幕頂部並定期(使用Timer,EnterFrame事件監聽器或setInterval)調用,當所有影片剪輯到達時停止調用此代碼頂部(使用Timer.stop(),removeEventListener或clearInterval)。 我不明白爲什麼你可能需要這樣做,因爲有很多補間庫爲你做這一切。
相關問題
- 1. 在屏幕上移動UIbutton
- 2. MKMapView在屏幕上移動
- 3. 將屏幕移動到屏幕上
- 4. 在屏幕上順暢地移動物體as3
- 5. 在iphone上的屏幕上移動UIView
- 6. AS3 - MovieClip上的AddEventLListener
- 7. 動畫MovieClip隨機跳過屏幕
- 8. 我可以「移動」屏幕,但屏幕上的物體仍在移動嗎?
- 9. 在屏幕上移動圖像
- 10. 在屏幕上移動鼠標光標
- 11. Javascript在屏幕上移動目標?
- 12. WPF在屏幕上移動的邊框
- 13. UIPopoverController可以在屏幕上移動嗎?
- 14. 在屏幕上移動立體視頻
- 15. 在屏幕IOS上移動圖像?
- 16. 使用NSMutablearray在屏幕上移動UILabels
- 17. 如何在屏幕上移動對象
- 18. 如何在屏幕上移動圖像?
- 19. 使對象在屏幕上移動iphone?
- 20. 在屏幕上選擇並移動Qwidget
- 21. 隨機移動星星在屏幕上
- 22. 滑動屏幕上的移動物體的歡迎屏幕
- 23. 向上移動屏幕上的矩形
- 24. 如何在AS3的屏幕上書寫
- 25. 在android中移動圖像部分在屏幕上移動
- 26. AS3的MovieClip屏蔽不工作[解決]
- 27. 當導航在屏幕上變化時,在另一個屏幕上移動div
- 28. 在AS3中選擇屏幕
- 29. as3加載屏幕
- 30. Android TranslateAnimation - 將屏幕右側的圖像移動到屏幕上
嘗試[TweenLite](http://www.greensock.com/tweenlite):'yourClip.y = stage.stageHeight; TweenLite.to(yourClip,1,{y:0});' –