loadVariablesNum problem

  • eurosickwitit
  • Beginner
  • Beginner
  • eurosickwitit
  • Posts: 62

Post 3+ Months Ago

Hellow flashers. I got a following problem. I want to dynamically load text from external text file using loadVariablesNum method. So i created a dynamic text field in root and gave it an instance name of "news". Then i set the variable name to "contents" and used it in my text file. Then in actions layer i have following code

Code: [ Select ]
loadVariablesNum("new.txt", 0);
function checkParamsLoaded() {
    if (_level0.done == undefined) {
        news.text = "Refreshing...";
        //------------
    } else {
        news.text = contents;
        clearInterval(param_interval);
        
    }
}

var param_interval = setInterval(checkParamsLoaded, 2000);
  1. loadVariablesNum("new.txt", 0);
  2. function checkParamsLoaded() {
  3.     if (_level0.done == undefined) {
  4.         news.text = "Refreshing...";
  5.         //------------
  6.     } else {
  7.         news.text = contents;
  8.         clearInterval(param_interval);
  9.         
  10.     }
  11. }
  12. var param_interval = setInterval(checkParamsLoaded, 2000);


It should clear the interval once it's loaded however when i test it text appears first as if it was loaded and then it changes to "Refreshing.." as if it was not loaded yet. What the hell is wrong with this.

HERE is the source file along with text file as well
http://home.comcast.net/~balticdesigns/ ... lesNum.zip

lostinbeta, anyone, HELP
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • mahjik
  • Novice
  • Novice
  • mahjik
  • Posts: 33
  • Loc: Las Cruces, NM USA

Post 3+ Months Ago

hello, maybe this will help. first of all, i don't really know loadvariablesnum, but loadVars works better according to everything I've read. I looked at your file, and the following code does what i think you need, if not then maybe i should reread your post. :)

Code: [ Select ]
announcements_txt.text = "Refreshing...";
// displays refreshing until data is loaded
// notice the change in spelling and variable suffix (_txt)

myLoader_lv = new LoadVars();
// creates the object that will load the data from the file
// case sensitive: loadVars is NOT the same as LoadVars

myLoader_lv.onLoad = function(){
   announcements_txt.text = myLoader_lv.contents;
   delete myLoader_lv;
}
// the onload event is triggered when myLoader is done loading the data,
// and your data was "Contents=this.....", so the myLoader object turned
// your data into a property of itself, so myLoader.contents contains your
// loaded data, and just assign it to the text field text property. Viola

// delete the loader object to free up memory unless you may need
// to use it again

myLoader_lv.load("new.txt");
// this actually starts the download
  1. announcements_txt.text = "Refreshing...";
  2. // displays refreshing until data is loaded
  3. // notice the change in spelling and variable suffix (_txt)
  4. myLoader_lv = new LoadVars();
  5. // creates the object that will load the data from the file
  6. // case sensitive: loadVars is NOT the same as LoadVars
  7. myLoader_lv.onLoad = function(){
  8.    announcements_txt.text = myLoader_lv.contents;
  9.    delete myLoader_lv;
  10. }
  11. // the onload event is triggered when myLoader is done loading the data,
  12. // and your data was "Contents=this.....", so the myLoader object turned
  13. // your data into a property of itself, so myLoader.contents contains your
  14. // loaded data, and just assign it to the text field text property. Viola
  15. // delete the loader object to free up memory unless you may need
  16. // to use it again
  17. myLoader_lv.load("new.txt");
  18. // this actually starts the download


hope that helps,

I don't like to preach, but i DO like to teach, so...

it is HIGHLY recommended to use standard suffixes for variable names. i.e. _mc for movie clips, _txt for text, etc. for 2 really good reasons

1. it enables code hinting in the authoring environment

2. it lets anyone (including yourself) who looks at your code know what type a variable is
  • eurosickwitit
  • Beginner
  • Beginner
  • eurosickwitit
  • Posts: 62

Post 3+ Months Ago

i tend to do that, however most fla's i post are 3 minute fla's that i dont really pay closer attention too, next time ill make sure everything is clear

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 9 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.