A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Flash 8 Preloader Problem

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Location
    Sydney
    Posts
    1

    Angry Flash 8 Preloader Problem

    3 days of head scratching..

    I created a preloader using the following:

    Frame 1:
    a = Math.round(getBytesLoaded()/1024);
    b = Math.round(getBytesTotal()/1024);
    c = Math.round((a/b)*100);
    if(_framesloaded == _totalframes)
    {
    gotoAndPlay(5);
    }

    Frame 1 also has a rectangular movieclip which has:
    onClipEvent(enterframe)
    {
    _xscale = _root.c;
    }

    Frame 4:
    gotoAndPlay(1);

    Frame 5 (also has the main animation within a movieclip):
    stop();

    Now, the movie clip on frame 5 is really heavy (1400 frames). When I publish, I don't see the preloader even in the bandwidth profiler. I have it uploaded as well (www.iconsolar.com.au - you will see how long it takes to load the swf), but the preloader doesn't show. When the entire animation loads, it plays it straight away skipping the first 4 frames.
    In the bandwidth profiler, it displays Frame: 0 and doesn't move to frame 1.

    What am I doing wrong? Anyone?

    Thanks in advance.

    AD

  2. #2
    Senior Member
    Join Date
    May 2008
    Posts
    332
    Seems like the basic math of the preloader is off. You're using bytes loaded and bytes total but then you jump to frames as a measurement in order to set off the gotoAndPlay action. If you measure the amount loaded in bytes then, then when bytes = 100% that will set off the gotoAndPlay action.
    Here's a sample preloaded that's using a mask but you still should be able to see the flow of the actionscript calculations from it.
    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

Tags for this Thread

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