A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: preloader for loadvariables - challenge or utopia?

  1. #1
    Member
    Join Date
    Aug 2001
    Location
    Poland
    Posts
    76

    preloader for loadvariables - challenge or utopia?

    Hello!

    (Flash 5)

    I'm using "loadvariables" command to load text from external php scripts. I was wondering if it was possible to do some sort of preloader for this, as some texts tend to be lenghty, and the server is on a slow connection.

    I've thought of something like this:

    in the php script which constructs the variables to be loaded I've included the size of the whole text to be loaded (variable is called "rozmiar"), as first variable in the row. It outputs something like this:

    ---8<------8<---
    rozmiar=12345&dTxt=here the text enters...blah blah blah...some more text...
    (...)
    &prelinks=some more text...
    &loadedOk = 1
    ---8<------8<---

    dTxt is the variable I load text into. prelinks is a supporting variable present if there are more additional links for the loaded text, but that's not important.

    Now the code which loads it is a typical 3-frames loop:

    At frame 1 loadvariables is called.
    At frame 2 is this:

    code:

    if (loadedOk ne "") {
    gotoAndPlay ("end");
    } else {
    // begin preload updater
    _root.sizeLoaded = _root.dTxt.length;
    if (_root.prelinks.length ne "") _root.sizeLoaded += _root.prelinks.length;
    _root.dPercent = Math.round((_root.sizeLoaded / _root.rozmiar) * 100);
    if (_root.dPercent le 100) {
    _root.displayLoaded = dPercent + "%";
    }
    }



    And at frame three is goto frame 2.

    Now for the idea. I thought if I could measure the dTxt.length (as dTxt is a string) I could get a functionality of getBytesLoaded for a variable loaded via loadvariables function. But the code above gives strange results (NaN, Infinity, sometimes true result :P) and seems not to update the dynamic text window used for displaying percentage loaded (_root.displayLoaded).

    Now I'm puzzled and stuck with it. Anyone know a cure for the problem? ;-)

    best regards,
    StarLight
    Last edited by StarLight{PL}; 05-20-2003 at 01:41 PM.
    Burn the past behind us
    and conquer the future!

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    some tests performed with F5 player and slow connection revealed that the entire data stream is parsed only after it has been received completely (i.e. the sender has closed the connection).
    So if there is any way to find out the current state of transmission, it would be an undocumented function, and the size variable would not be parsed either.

    Musicman

  3. #3
    Member
    Join Date
    Aug 2001
    Location
    Poland
    Posts
    76

    thx :(

    Hmmm... This explains why there are sometimes NaN's and sometimes values like 98%. Sad. I don't have any other idea for this. It would be good to have this functionality around. Alas.
    Burn the past behind us
    and conquer the future!

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