Need help with a Preloader in FLASH CS3...

Discussion in 'Web Design and Development' started by Molson1020, Apr 27, 2010.

  1. Molson1020 macrumors regular

    Joined:
    Feb 3, 2009
    #1
    So I am building a portfolio site in Flash CS3 and have everything pretty much running except I can't get the preloader to work.

    Here is the script I have so far:

    //LOAD A RANDOM BACKGROUND

    var randomNumber:Number = Math.ceil(Math.random()*10);

    trace(randomNumber);

    bkgdimage.source = "images/bkgd"+randomNumber+".jpg";
    var myalphaTween:Tween = new Tween(bkgdimage, "alpha", Regular.easeOut, 0, 2, 1, true);
    bkgdimage.addEventListener(ProgressEvent.PROGRESS, largeImagePreloader);
    function largeImagePreloader(event:progressEvent):void {
    var percent:Number = Math.round((event.bytesLoaded*100)/event.bytesTotal);
    percent_txt.text = percent + "%";
    bkgdimage.addEventListener(Event.COMPLETE, fadeIn);

    function fadeIn(e:Event):void {


    }
    }


    but what happens is that after the background image loads, the percentage still stays there and won't go away. I would also prefer to have the preloader start before ANYTHING is loaded on the page.

    Here is the site: www.MatthewOlson.net

    The crossbar, and the four buttons always load first, with the background loading quickly afterwards. Can anyone help me out?
     
  2. Ride9650 macrumors 6502

    Joined:
    Jun 29, 2007
    #2
    Can I assume correctly that your code to bring in the crossbar, text, etc is within the fadein function? Because if its not, then thats your problem right there.

    Otherwise, it looks like it should work, but I do have a couple ideas of other things you could try.

    1. pre-loading the background first doesn't exactly make a lot of sense. It makes much more sense to animate your site the way you want it, then slap a preloader on that.

    2. Instead of using Event.COMPLETE you could try an if statement, for instance:

    if(percent != 100{
    "preload my background";
    }else if(percent == 100){
    "load background...then load other stuff";
    }

    3. use a loader object instead to bring in the background

    var myURLRequest:URLRequest = new URLRequest("/file/to/my/image");
    var loader:Loader = new Loader(myURLRequest);
    addChild(loader);


    Lastly, the reason the pre-loader text isn't going away is because you haven't told it when to do so.
    You need to call "removeChild("percent_text")" to get it off the screen. Also, as a general tip, its usually helpful to keep things neatly spaced out, I had a little bit of trouble following the code at first.

    I also had a few thoughts on the site itself:
    - I noticed that the "about me" button doesn't get bigger when you hover the mouse over it like the other buttons.
    - Also, since you're trying to promote yourself as a professional, having a huge ad at the very top saying you're getting free hosting, is kinda ridiculous especially since hosting is cheap to begin with.
    -Finally, I would try to keep your font choice consistent. Did you use comic sans for the buttons? Thats a big no-no in the art world!
     
  3. Molson1020 thread starter macrumors regular

    Joined:
    Feb 3, 2009
    #3
    Thanks for the helpful reply. I'll keep messing around with the code. This is my first foray into Flash.

    I was having trouble with the "About Me" getting bigger... I need to keep working on that.

    Regarding the ads on the top, I am contacting GoDaddy this week to have them removed (it costs $5 a month).

    It wasn't Comic Sans... but I didn't know that it was a big no no (I only know that Papyrus is hated). I'll be changing that up too.

    Thanks!
     

Share This Page