• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 806
  • Last Modified:

How do I add a Simple Preloader Animation while a FLV file Buffers in Flash AS3

I have a 7 meg FLV file which streams very nicely using the FLVPLayback component in Flash CS3.  It does a very nice job of waiting for the FLV file to buffer before playing which allows for steady playback,  however, there is currently about 5 seconds of dead time while the FLV file buffers.  Sometimes longer when viewed over a wireless connection.  I would like to add just a simple Circle Youtube Style animation at the beginning of the file to allow the users to know that a file is loading. No progress bar required.    
Please help !
0
JohnTregaskiss
Asked:
JohnTregaskiss
  • 2
1 Solution
 
deepanjandasCommented:
Use the VideoEvents like State changes to track when bufferring starts and ends (BUFFERING_STATE_ENTERED), based on that show/hide the bufferring animations.
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html#event:bufferingStateEntered

Warm Regards
Deepanjan Das
0
 
JohnTregaskissAuthor Commented:

My FLV file is called trailer.flv, instance name trailer
I'm supposing i need to create a movie clip for the preloader. lets call it preloader
Do I put the Preloader on Frame1, Trailer on Frame2, and then add actions to FRame 1 telling it to go to rame 2 once the buffer is complete.  If so, what would my AS look like?
0
 
deepanjandasCommented:
You are right, need to create a preloader movieclip.
Now place the FLVPlayback component on frame 1 layer 1. place the preloader on layer 2 above the component.
Now add the buffering listener with the FLVPlayback component as shown in the link above.

On buffering start set the preloader clip's visibility to true and to false when playing starts.

Hope this helps :)

Warm Regards
Deepanjan Das
0
 
sketchbooksharkCommented:
OK, deepanjandas did a pretty good job of explaining it. I don;t know if that solved your problem. You asked for the code so I typed it up for you. See below

Create a buffer Animation as a Movie-Clip-symbol in your library. In the example below I gave it the Class-Name: "YourMovieClipSymbolsName".

With a left click on the symbol in the library you can pull up the properties window.
Under Advanced checkmark "Export for Actionscript" & "Export in Frame 1"

Via Code cretae an Instance of it in Frame 1 (if it says it does not know the class in frame 1, try it in Fame 2).IN the example I called this instance:"bufferAnimation".

Attache Listeners as shown to your FLVPlayback Instance (You said it was called trailer) and use the Listeners to add and remove your instance of the buffer Animation to/from the Display list

Carefull, if you did not add the instance of the FLVPlayback through Code in frame 1, the Flash might not see it in Frame 1. Hence you can only attach the listeners in Frame 2
var bufferAnimation:YourMovieClipSymbolsName = new YourMovieClipSymbolsName();


 trailer.addEventListener(VideoEvent.BUFFERING_STATE_ENTERED, showBufferAnimation);
 trailer.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, removeBufferAnimation);

function showBufferAnimation(e:VideoEvent){
	addChild(bufferAnimation);
};

function showBufferAnimation(e:VideoEvent){
	removeChild(bufferAnimation);
};

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now