Preloader working, audio starts on video but preloader still shows

Posted on 2006-05-08
Last Modified: 2012-08-14
It's been long and long since I worked with Flash, and this one has me stumped.  This seems to be worse when it's on my server, but it's still reproducible locally.  I have a Flash file that loads external .swfs (all videos) into a Loader component.  I have a preloader that uses getBytesLoaded() and getBytesTotal() to both update itself and to determine when the movie gets to play.  So far, so good.  Unfortunately, it might be showing only 5 or 10% loaded, but the audio starts on the video!  Still can't see the video itself until the preloader hits 100%.  I've tried changing the threshold for when the movie should start playing, but it doesn't make a difference: audio still starts way before the preloader is complete, and it doesn't want to hide early either.

I tried using the ProgressBar component with the same results.

Any idea what I can do to keep the movie clip loaded into the Loader from starting until I say so?
Question by:valkyrie_nc
    LVL 2

    Expert Comment

    Are you loading the videos as videos converted into SWFs or as FLVs?
    LVL 9

    Author Comment

    They're FLVs embedded into .swfs, so the file being loaded is a .swf
    LVL 2

    Accepted Solution

    This is a function I use to calculate an FLV's load percent.. it uses bufferLength and bufferTime. Not sure if that will help you. I load my flvs into a video object and control them without components. It's alot lighter and easier to work with than dealing with swfs once you get the hang of it.

    videoProgress.onEnterFrame = function() {
                nsBufLen = stream_stream.bufferLength;
                bLoaded = Math.floor(stream_stream.time);
                vidPercentLoaded = 100*(Math.floor(nsBufLen)/stream_stream.bufferTime);
                videoProgress.loadText.text = "LOADING: "+vidPercentLoaded+"%";
                if ((vidPercentLoaded<99)) {
                      videoProgress.progressBar._xscale = vidPercentLoaded;
                      videoProgress.progressBar._alpha = 100;
                } else {
                      videoProgress.progressBar._xscale = 100;
                      videoProgress.onEnterFrame=function() {
                            if(videoProgress._alpha<1) {
    LVL 2

    Expert Comment

    note: here's the first part of the code that would actually load the flv and set the volume etc:

          var connection_connection;
          var stream_stream;
          my_video._alpha = 100;
          playVideo = function () {
                connection_connection = new NetConnection();
                stream_stream = new NetStream(connection_connection);
                this.createEmptyMovieClip("movFLVAudio", this.getNextHighestDepth());
                var snd1:Sound = new Sound(movFLVAudio);
                stream_stream.onMetaData = function(obj) {
                      _global.bufTime = obj.duration;
                      totalPlayTime = obj.duration;

    LVL 9

    Author Comment

    Thanx, rythmik1 :)  I'll give it a try & see if it behaves itself better.  Appreciate the info. :)

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
    Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
    In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
    The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now