A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: video getbythes preloader problem

  1. #1
    Member
    Join Date
    May 2002
    Posts
    70

    video getbythes preloader problem

    preloader for video
    I know there has to be a get byte preloader somewhere but I can't seem to find a sample--does anyone know of tutorial to help with this.
    Is this the correct way to preload video--I'm kinda confused with this one
    THANKS

    this is the code I tried:


    onClipEvent(data){
    //preload code
    trace("data received");
    _root.transferIndicator.gotoAndStop("on");
    //if loaded let the movie play
    if(getBytesTotal() > 0&&getBytesLoadedd() ==getBytesTotal()){
    _root.transferIndicator.gotoAndStop("off");
    play();
    }
    //display feedback

    _root.bytesLoaded = getBytesLoaded();
    _root.bytesTotal = getBytesTotal();
    _root.clipURL = _url.substring(_url.lastIndexOf("/") +1, _url.length);

    };

    The problem is that MX doesn't like the

    onClipEvent(data){

    It gives me the error that onClip Events are for movie clips and I don't know how to correct it please help

  2. #2
    Moderator
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    since you are dong Flash video you can take advantage of Flash 6 actionscript features to simplify the preloader code process a little.

    you dont use the data event, this is for loading data variables from a text file or server side process.

    create an empty mc, assign its enterFrame loop to a function to track load progress and delete enterFrame loop when percent is 100.

    Code:
    createEmptyMovieClip("loader",0);
    
    function showLoad(mc){
       if(mc.getBytesTotal() > 0) {//wait for loading
          percent = Math.floor(mc.getBytesLoaded()/mc.getBytesTotal() * 100)
          trace(percent); // display percent
          if(percent == 100){ // loaded
               trace("loaded");
               mc.enterFrame = null; // terminate loop
          }
       } else {
          trace("connecting");
       }
    }
    
    loader.enterFrame = function() {showLoad(targetpath);}
    aviarts.com - web development and flash development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center