Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / May 2006



Tip: Looking for answers? Try searching our database.

LoadVars and onLoad question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nagromme - 17 May 2006 19:28 GMT
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.)
cinemaguy - 19 May 2006 15:13 GMT
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?
Motion Maker - 23 May 2006 00:30 GMT
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.

Signature

Lon Hosford
www.lonhosford.com
May many happy bits flow your way!

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.)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.