A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Someone please look at my FLA and tell me why my simple Preloader isn't working!!

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    209

    Someone please look at my FLA and tell me why my simple Preloader isn't working!!

    http://s91931107.onlinehome.us/photography.fla

    Button #1 loads the jpg when you click it, and the dynamic textbox displays percent loaded just fine. But how come the dynamic textbox says 100% before i click button #1, and why does it remain at 100% after the jpg is done loading.

    Please take a look at my .fla, its probably pretty obvious to someone who knows what their doing. I'm new to this. Thanks!

  2. #2
    Master Poo Flinger
    Join Date
    Sep 2000
    Posts
    318
    it says its at 100% before you click the button because you're checking the "holder" before anything is loaded into it. so technically, holder's contents are already loaded (i think its 4 bytes for an empty movieclip).

    and the 3 frames are a little unnecissary for the percentage checking. its like having 2 onEnterFrame functions. this is a little generic and you should think it though more, but try this:

    delete frames 2 & 3.

    and in frame 1:
    Code:
    this.progressCheck = function()
    {
       var bl = myHolder.getBytesLoaded();
       var bt = myHolder.getBytesTotal();
       var percent = Math.round((bl * 100) / bt);
       loadText = percent + '%';
       if (bl > 5 && percent >= 100) {
          loadText = '';
          delete this.onEnterFrame;
       }
    }
    now for you buttons:
    Code:
    on(release){
       _root.myHolder.loadMovie('something.jpg');
       _root.onEnterFrame = _root.progressCheck;
    }
    i remeber seeing a great tutorial on a flash photo album, but this is the first time i've posted here in a really long time. maybe one of the other forum goers would be kind enough to point you to it
    monkeys rawk

  3. #3
    Senior Member
    Join Date
    Apr 2001
    Posts
    209
    Thanks! It works... but theres still a problem. The textbox says "_level0" untill i click the button. Once i click the button it displays percentage and then the text dissapears when the image loads like its supposed to. But why does it say "_level0" originally?

    And also, when i assign the other buttons to load different images, whatever button i click first will load the image fine, but then when i click a different button the text field displays "NaN" and no image is displayed. WTH is that? Thanks.
    Last edited by gragland; 01-19-2004 at 04:50 PM.

  4. #4
    Master Poo Flinger
    Join Date
    Sep 2000
    Posts
    318
    try deleting "loadText" from the "instance name" field in the property inspector, not the "var" field.

    with the instance name, to set the text youd have to use: loadText.text = 'blah blah'.

    with this the var name, to set the text:
    loadText = 'blah blah'.

    so it was just being normal and setting the text to the instance's name.

    var loadText = _level0.loadText

    i think that makes sense
    monkeys rawk

  5. #5
    Senior Member
    Join Date
    Apr 2001
    Posts
    209
    Originally posted by tweekmonster
    try deleting "loadText" from the "instance name" field in the property inspector, not the "var" field.

    with the instance name, to set the text youd have to use: loadText.text = 'blah blah'.

    with this the var name, to set the text:
    loadText = 'blah blah'.

    so it was just being normal and setting the text to the instance's name.

    var loadText = _level0.loadText

    i think that makes sense
    OK that worked! But then i then click a different button (using the same code as the first button except its linked to a different image), the loadText displays "NaN" and no image is loaded. Know what thats about? Do i have to make it unload the first image before it loads its image?

  6. #6
    Master Poo Flinger
    Join Date
    Sep 2000
    Posts
    318
    oops, didn't see your edit in the prev post.
    not really sure on that one. unloading the movieclip may help. but then again, make sure the file you're loading really does exist. i've never really had this problem unless its a little detail like spelling or case sensitivity.

    if you're testing it from within the flash program, you should get an error message saying that it couldn't load whatever you were loading.
    monkeys rawk

  7. #7
    Senior Member
    Join Date
    Apr 2001
    Posts
    209
    Originally posted by tweekmonster
    oops, didn't see your edit in the prev post.
    not really sure on that one. unloading the movieclip may help. but then again, make sure the file you're loading really does exist. i've never really had this problem unless its a little detail like spelling or case sensitivity.

    if you're testing it from within the flash program, you should get an error message saying that it couldn't load whatever you were loading.
    I'll explain the situation exactly and maybe you will notice something I'm doing wrong.

    ---------------------

    I have a flash site with one frame on the _root layer. On that frame is the code:

    this.progressCheck = function() {
    var bl = myHolder.getBytesLoaded();
    var bt = myHolder.getBytesTotal();
    var percent = Math.round((bl*100)/bt);
    loadText = percent;
    if (bl>5 && percent>=100) {
    loadText = "";
    delete this.onEnterFrame;
    }
    };


    There is an empty movieclip called "myHolder", and a Dynamic Text field with the var name "loadText" on the _root layer. Just like there should be.



    I have a button with the code:

    on (release) {
    _root.myHolder.loadMovie('boat.jpg');
    _root.onEnterFrame = _root.progressCheck;
    }


    I have another button with the code:

    on (release) {
    _root.myHolder.loadMovie('house');
    _root.onEnterFrame = _root.progressCheck;
    }


    When i click the first button everything works fine. The text field displays the percent loaded and then boat.jpg appears.

    But, when i click the other button, or the same button again. Nothing loads and the textfield just says "NaN". Then if i click another button again, it loads the image like its supposed to.

    WHAT AM I DOING WRONG? DO I NEED TO UNLOAD THE IMAGE IN myHolder BEFORE IT CAN LOAD ANOTHER IMAGE? If so, whats the code and where do i put it. (PS. NaN stands for "not a number")

    ----------------

    Any help would be much appreciated!
    Last edited by gragland; 01-19-2004 at 08:10 PM.

  8. #8
    Master Poo Flinger
    Join Date
    Sep 2000
    Posts
    318
    i'm not a flash n00b

    if the AS you posted is EXACTLY as you have it in your fla, the only problem i see is:

    on (release) {
    _root.myHolder.loadMovie('house');
    _root.onEnterFrame = _root.progressCheck;
    }

    perhaps you need it to be house.jpg?

    if it's working for your other buttons, that would be the only problem that i see.
    monkeys rawk

  9. #9
    Senior Member
    Join Date
    Apr 2001
    Posts
    209
    Originally posted by tweekmonster
    i'm not a flash n00b

    if the AS you posted is EXACTLY as you have it in your fla, the only problem i see is:

    on (release) {
    _root.myHolder.loadMovie('house');
    _root.onEnterFrame = _root.progressCheck;
    }

    perhaps you need it to be house.jpg?

    if it's working for your other buttons, that would be the only problem that i see.
    Well, I moved my operation to another computer and now it magically works! Weird. Anyway, thanks for the help!

    Site is: http://ragland.freeservers.com/photosite.html

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