PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Flash8 AS2 | Preloader issues...
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: AS2 | Preloader issues...

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    11

    AS2 | Preloader issues...

    Hi everybody, I just realized, that my preloader isn't actually working, and all thanks to trying to load the page on a PC with quite slow internet... The story is following - my preloader animation plays, but only after the whole movie is loaded, cuz I noticed a huge delay before the preloader was actually played... And then I used that flash speed testing thing (sorry, but I don't know how it's called) and it proved my theory...
    That's the code on 1-st frame, where preloader is:
    Actionscript Code:
    stop();
    var loaded:Number = getBytesLoaded();
    var total:Number = getBytesTotal();
    var percent:Number = Math.floor((loaded*100)/total);
    if (loaded == total){
    gotoAndPlay (2);
    }else{
        _preloader.gotoAndPlay(percent);
        //loadBar.percentage.text = percent;
    }

    And preloader itself has
    Actionscript Code:
    _parent.gotoAndPlay(2);
    on it's frame 100.

    Can anybody tell me, where is my mistake?
    Last edited by oojustinoo; 03-15-2010 at 10:15 PM.

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    Well I've never been great at preloaders, but it appears that your preloader and your movie are one in the same. When I use a preloader, it is separate from the actual movie I am loading. For instance, I use what I like to call a "base" page. This page acts as the container for all other movies and contains the code for the preloader.

    The base page loads completely then I have a function that immediately starts loading the main page. My preloader displays the loading process of the main page without delay because the preloader (base page) is already loaded. I load the main page into an empty movieclip on the stage, so I am NOT replacing my base page, just loading a new page into it.

    Does that make sense?
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    Sort off, even though not 100%... But the point is, that my web page is almost done, so rebuilding all of it seems like a bit of pain in the as$... The code is on the first frame of main movie and a preloader movie is a separate movie clip placed on that first frame... Technically it should work, I just can't find the mistake... However, thanks for trying to help...

  4. #4
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    I don't want you to misunderstand, it isn't a mistake. You code is running correctly, but since the preloader isn't completely loaded when you want it to be, it can't run as a preloader. The best part about making a base page, is you're not losing all the work you've done. You are simple separating the preloader from the main page.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  5. #5
    Senior Member
    Join Date
    May 2008
    Posts
    332
    Well yes, if you preloader is in frame 1 and your movie is in frame 2, how can the preloader have anything
    on it's frame 100.
    ? If the preloader is in frame 1, then that's all there should be... with the rest of the movie in frame 2 and on.
    Here's working code for a preloader that uses a mask to uncover an image as a cue to the percent of the file loaded. Perhaps you can adapt parts as needed:
    Code:
    stop();
    mask_mc._height = 1;
    this.onEnterFrame = function():Void {
    	var loadedData:Number = this.getBytesLoaded();
    	var allData:Number = this.getBytesTotal();
    	var percent:Number = Math.round(loadedData/allData*100);
    	mask_mc._yscale = percent;
    	if (loadedData>=allData) {
    		gotoAndStop(10);
    		delete this.onEnterFrame;
    	}
    };
    Best wishes,
    Eye for Video
    www.cidigitalmedia.com

  6. #6
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    Well, my preloader is a separate movie clip in the library, that is placed on frame 1, but that preloader clip itself has 100 frames.

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