PDA

View Full Version : [AS3] FLVPlayback - Preload before loading to player


fikeiv
03-06-2009, 10:36 AM
Hi folks. Im Newbie to Flash and ActionScript 3, and making a talking heads flash menu.

I have several videoclips responding to buttons in my menu.
What I want is:

- I have a flv-loop (sale1_loop.flv) in a FLVPlayback component (myVideo).
- When I click a button (btn1) I want nother clip (sale1_new.flv) to be loaded into the flash, and then, when some of the sale1_new.flv file is loaded - I want it to replace sale1_loop.flv.

In other words: I need the filmclip (flv) to be partial preloaded BEFORE I replace the previous clip. So that the cliping between them is minimal (or none :)).

Today I have the following script to do this:

import fl.video.*;
var myVideo:FLVPlayback = new FLVPlayback();

myVideo.source = "sale1_loop.flv";
myVideo.width = 230;
myVideo.height = 153;
addChild(myVideo);

btn1.addEventListener(MouseEvent.CLICK, lnk1Action);

function lnk1Action(e:MouseEvent):void
{
myVideo.load("sale1_new.flv")
myVideo.play();
}

The code do the job of changing the flv in the player, BUT!!! It also makes a "one second" break in the filmplay (sale1_loop.flv dissapear - blank in one second - and then sale1_new.flv shows up). I also have a script for going back to sale1_loop.flv after ending the sale1_new.flv clip.

Here it is:

myVideo.addEventListener(VideoEvent.COMPLETE, completePlay);
function completePlay(e:VideoEvent) {
myVideo.load ("Selger2_loop.flv");
myVideo.play();
}

Anyone who can help me? :) THANKS!!!