Professional Web Applications Themes

LoadVars and onLoad question - Macromedia Flash Data Integration

I'm using LoadVars in Frame 1, and I need to use the resulting variables in other scripts afterwards. (But all the examples I find online only use the variables right in the same script.) The problem I'm having is, the onLoad function doesn't actually make it wait. It goes ahead to the next frame whether fully loaded or not. It depends on the connection at the moment--if the vars haven't fully loaded, hilarity ensues. <b>My script in Frame 1:</b> _root.myloadvars = new LoadVars(); _root.myloadvars.load("datapairs.txt"); _root.myloadvars.onLoad = function(success) { if (success) { //trace("TXT RETRIEVED"); gotoAndPlay(2); } else { trace("TXT NOT RETRIEVED"); ...

  1. #1

    Default LoadVars and onLoad question

    I'm using LoadVars in Frame 1, and I need to use the resulting variables in
    other scripts afterwards. (But all the examples I find online only use the
    variables right in the same script.)

    The problem I'm having is, the onLoad function doesn't actually make it wait.
    It goes ahead to the next frame whether fully loaded or not. It depends on the
    connection at the moment--if the vars haven't fully loaded, hilarity ensues.

    <b>My script in Frame 1:</b>

    _root.myloadvars = new LoadVars();
    _root.myloadvars.load("datapairs.txt");
    _root.myloadvars.onLoad = function(success) {
    if (success) {
    //trace("TXT RETRIEVED");
    gotoAndPlay(2);
    } else {
    trace("TXT NOT RETRIEVED");
    gotoAndPlay(1);
    }
    };


    <b>It's SUPPOSED to hold in Frame 1 until ready to proceed and make use of the
    variables in Farme 2.

    Things I have tried:</b>

    * Moving the above to Frame 2, so the "not retrieved" loop actually has two
    frames to cycle (back to 1, then forward to 2 where the script it).

    * Adding an additional gotoAndPlay(1) BELOW the above.

    But regardless, it never goes back to Frame 1, it always goes forward. It
    reports success, but half the time the variables (or some of them) are still
    Undefined.

    What's the RIGHT way to wait in a frame for LoadVars, and then let other
    scripts use the variables afterwards?

    <b>Many thanks for any advice!</b>

    (PS, this is Flash MX--I'm waiting for Universal Binary before I upgrade.)

    nagromme Guest

  2. #2

    Default Re: LoadVars and onLoad question

    this may not be what you are looking for or even the right idea but why
    couldnt you just use a preloader to wait until it is finished loading
    the variables?

    cinemaguy Guest

  3. #3

    Default Re: LoadVars and onLoad question

    You need a stop() on the frame doing the load and onLoad. Then in the onLoad
    you move to the next frame. Other approaches include hiding the UI and in
    the onLoad, revealing the UI such as a MovieClip cover is made invisible.

    Declare the results LoadVars object on the timeline outside of a function
    and it is accessible for the entire movie at all levels.

    --
    Lon Hosford
    [url]www.lonhosford.com[/url]
    May many happy bits flow your way!
    "nagromme" <webforumsusermacromedia.com> wrote in message
    news:e4fpvm$qmq$1forums.macromedia.com...
    I'm using LoadVars in Frame 1, and I need to use the resulting variables in
    other scripts afterwards. (But all the examples I find online only use the
    variables right in the same script.)

    The problem I'm having is, the onLoad function doesn't actually make it
    wait.
    It goes ahead to the next frame whether fully loaded or not. It depends on
    the
    connection at the moment--if the vars haven't fully loaded, hilarity ensues.

    <b>My script in Frame 1:</b>

    _root.myloadvars = new LoadVars();
    _root.myloadvars.load("datapairs.txt");
    _root.myloadvars.onLoad = function(success) {
    if (success) {
    //trace("TXT RETRIEVED");
    gotoAndPlay(2);
    } else {
    trace("TXT NOT RETRIEVED");
    gotoAndPlay(1);
    }
    };


    <b>It's SUPPOSED to hold in Frame 1 until ready to proceed and make use of
    the
    variables in Farme 2.

    Things I have tried:</b>

    * Moving the above to Frame 2, so the "not retrieved" loop actually has two
    frames to cycle (back to 1, then forward to 2 where the script it).

    * Adding an additional gotoAndPlay(1) BELOW the above.

    But regardless, it never goes back to Frame 1, it always goes forward. It
    reports success, but half the time the variables (or some of them) are still
    Undefined.

    What's the RIGHT way to wait in a frame for LoadVars, and then let other
    scripts use the variables afterwards?

    <b>Many thanks for any advice!</b>

    (PS, this is Flash MX--I'm waiting for Universal Binary before I upgrade.)


    Motion Maker Guest

Similar Threads

  1. Sending email, problem with onLoad question
    By mdawg0916 in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: February 25th, 02:58 PM
  2. When using LoadVars in a class the scope changes in onLoad function
    By cherry_x in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: February 5th, 07:56 PM
  3. loadVars component question
    By terapsta webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 5
    Last Post: January 27th, 05:27 PM
  4. Onunload & onload question
    By Matthew Tan in forum Informix
    Replies: 3
    Last Post: October 22nd, 07:33 AM
  5. Simple onload question..i think I know but...
    By darrenbartlett webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 11th, 11:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139