Reputation: 553
Say I have a .flv containing 180 frames at fullHD.
I import this into Flash (or flex), and want to be able to smoothly navigate through the timeline by clicking and dragging the view.
How would I do this?
My current solution is to load each frame into a BitmapData array, which works, but it uses 1,5 GB memory, which might be causing me some of my problems.
I only need a way to be able to click and drag left/right to scroll through the frames forwards/backwards, smoothly.
In my simple tests it's really laggy.
This is my simple test code, which is waaaay 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;
}
}
Upvotes: 0
Views: 142
Reputation: 3
yeah... stream the data, if it runs locally as I assume it does given the size, shouldn't be an issue, load the frames closest to the current frame on either side and get rid of the other ones... Also, are you sure you need full HD video? Sometimes you can stretch it out and hardly feel the loss of quality... also, dont use a bitmapdata array, thats just huge, make sure you've got it compressed...
Upvotes: 0
Reputation: 6732
I think you should re-compress your video file adding a keyframe every frame (keyframe distance = 1) - in Adobe Media Encoder there is an option to set said distance.
The resulting file will be larger than it's now, but should be smaller than 180 bitmaps.
When embedding in the timeline make sure you do not change the keyframe distance.
Flash can 'jump' only to a frame called 'keyframe', if the video is on the timeline it can jump to any frame, but it has to read the keyframe first and then do some heavy calculations, so it's laggy.
Upvotes: 1
Reputation: 1890
May be you have to store your pictures separately from SWF, loading them by one, when it's needed? I mean, you can use URLLoader class to load your bitmaps, saving loader.data into Bitmap-typed object and then displaying it. Of course, you have to remove your previous picture every time, you're loading a new one.
Upvotes: 0