Flash-在MovieClip中平滑滚动

Flash-在MovieClip中平滑滚动,flash,apache-flex,movieclip,Flash,Apache Flex,Movieclip,假设我有一个.flv,在全高清下包含180帧 我将其导入到Flash(或flex)中,并希望通过单击和拖动视图能够在时间线中顺利导航 我该怎么做 我目前的解决方案是将每个帧加载到一个BitmapData数组中,这是可行的,但它使用1,5 GB内存,这可能会给我带来一些问题 我只需要一种能够点击并向左/向右拖动的方式,就可以顺利地向前/向后滚动帧 在我的简单测试中,它真的很滞后 这是我的简单测试代码,它是waaay to laggy: import flash.events.Event; impo

假设我有一个.flv,在全高清下包含180帧

我将其导入到Flash(或flex)中,并希望通过单击和拖动视图能够在时间线中顺利导航

我该怎么做

我目前的解决方案是将每个帧加载到一个BitmapData数组中,这是可行的,但它使用1,5 GB内存,这可能会给我带来一些问题

我只需要一种能够点击并向左/向右拖动的方式,就可以顺利地向前/向后滚动帧

在我的简单测试中,它真的很滞后

这是我的简单测试代码,它是waaay to 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;
    }
}
导入flash.events.Event;
导入flash.events.MouseEvent;
停止();
var mouseDownValue:Boolean=false;
var currentFrameValue:int=0;
var maxFramesValue:int=180;
var-oldMouseX:int;
myMovie.addEventListener(MouseEvent.MOUSE\u DOWN,mouseDownHandler);
myMovie.addEventListener(MouseEvent.MOUSE\u UP,mouseHandler);
myMovie.addEventListener(MouseEvent.MOUSE\u MOVE,mouseMoveHandler);
函数mouseDownHandler(evt:MouseEvent):void{
mouseDownValue=true;
}
函数MouseHandler(evt:MouseEvent):void{
mouseDownValue=false;
}
函数mouseMoveHandler(evt:MouseEvent):void{
if(mouseDownValue){
如果(oldMouseX=(maxFramesValue-2))currentFrameValue-=(maxFramesValue-1);

如果(currentFrameValue可能您必须将图片与SWF分开存储,在需要时逐个加载?我的意思是,您可以使用URLLoader类加载位图,将loader.data保存到位图类型的对象中,然后显示它。当然,每次加载新图片时,您都必须删除以前的图片。

您应该重新压缩视频文件,每帧添加一个关键帧(关键帧距离=1)-在Adobe Media Encoder中,有一个选项可以设置所述距离

生成的文件将比现在大,但应小于180位图

嵌入时间轴时,请确保不更改关键帧距离


Flash只能“跳转”到一个名为“关键帧”的帧,如果视频在时间轴上,它可以跳转到任何帧,但它必须先读取关键帧,然后进行一些繁重的计算,因此它很滞后。

是的……流式传输数据,如果它在给定大小的情况下在本地运行,应该不会有问题,加载最接近当前帧的帧两边都是t帧,去掉其他的…还有,你确定你需要全高清视频吗?有时候你可以把它拉伸,几乎感觉不到质量的损失…还有,不要使用位图数据阵列,它太大了,确保你已经将它压缩了…

我知道这很旧,但从我这里得到了+1,因为这修复了我在视频中遇到的一个问题在Flash中显示时间线。谢谢!