說我有一個.flv包含fullHD的180幀。Flash - 順利滾動MovieClip
我將其導入到Flash(或flex)中,並且希望能夠通過單擊並拖動視圖來平滑瀏覽時間軸。
我該怎麼做?
我目前的解決方案是將每個幀加載到一個BitmapData數組中,該數組可以工作,但它使用1,5 GB的內存,這可能會導致我的一些問題。
我只需要一種方法能夠點擊並拖動左/右來平滑地向前/向後滾動幀。
在我的簡單測試中,它確實很滯後。
這是我簡單的測試代碼,這是waaaay到laggy:
import flash.events.Event;
import flash.events.MouseEvent;
stop();
var mouseDownValue:Boolean = false;
var currentFrameValue:int = 0;
var maxFramesValue:int = 180;
var oldMouseX:int;
myMovie.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
myMovie.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
myMovie.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
function mouseDownHandler(evt:MouseEvent):void{
mouseDownValue = true;
}
function mouseUpHandler(evt:MouseEvent):void{
mouseDownValue = false;
}
function mouseMoveHandler(evt:MouseEvent):void{
if(mouseDownValue){
if(oldMouseX<0) oldMouseX = mouseX;
currentFrameValue += (oldMouseX - mouseX)/2;
if(currentFrameValue>=(maxFramesValue-2)) currentFrameValue -= (maxFramesValue-1);
if(currentFrameValue<0) currentFrameValue += (maxFramesValue-1);
myMovie.gotoAndStop(currentFrameValue+1);
oldMouseX = mouseX;
}
}
我知道這是舊的,但+1從我這裏解決了我在Flash中使用視頻時間線上的問題。謝謝! – 2014-04-22 09:23:22