A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: a preloader in cs3

  1. #1
    Junior Member
    Join Date
    Jan 2009
    Posts
    2

    a preloader in cs3

    I am trying to make a preloader, I've tryied 3 different tutorials but every time it doesn't work.
    I the last I did there is a image layer with the image to load on the second key frame, a bar layer with the movie clip of the bar that should reflect the download amount, instance name: bar, then a border layer that is just the border of the bar, and a text layer that contains an empity dynamic text box with instance name of "loadBox"
    and this is the code

    stop();
    var percentage: Number;
    onEnterFrame = function()
    {
    if(getBytesLoaded()> = getBytesTotal())
    {
    gotoAndStop(2);
    delete onEntreFrame;
    }
    percentage = Math.round((getBytesLoaded()/getBytesTotal())*100);
    bar._xscale = percentage;
    loadBox.text = percentage + "%loaded";
    }



    but the animation loops between these two frames.
    I really can't see what the problem is since I don't understand much about actionscript yet.
    Please help me.
    Thankyou guys!

  2. #2
    Junior Member
    Join Date
    Aug 2007
    Posts
    2
    I'm a newbie, but this works well and will give you a better start.
    Just have a dynamic Text box with an instance name txtBox for it to output to:


    stop();
    //this script loads itself ...best attached to the content file.
    addEventListener(Event.ENTER_FRAME, loading);

    function loading(event:Event)
    {
    var bytestotal = stage.loaderInfo.bytesTotal;
    var bytesloaded = stage.loaderInfo.bytesLoaded;
    var percentage = Math.round(bytesloaded*100/bytestotal);
    txtBox.text = percentage + "%"; //inputs % in dynamic text box instance name txtBox
    if (bytesloaded >= bytestotal)
    {
    gotoAndPlay(2);
    removeEventListener(Event.ENTER_FRAME, loading);
    }
    }

  3. #3
    Junior Member
    Join Date
    Jan 2009
    Posts
    2

    thanks I'll try that

    Hey, in the end the problem, I think, was that I was using as 2.0
    But still it's difficult because there are many different ways to get to the same result.
    I'll try your solution too.
    Thanks a lot!

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