Groups | Blog | Home
all groups > flash data integration > october 2005 >

flash data integration : Help using LoadVars()


FurToy
10/7/2005 12:00:00 AM
Folder has "money.txt" and "money.fla"
Money.txt has just one variable...
&money=500

In Frame 1, of action layer, I just want to trace out in the output window the
value of money in the money.txt. I can't even get that to work.

//Create instance of LoadVars
var myData:LoadVars = new LoadVars();

// Load Data into the LoadVars object.
myData.load("money.txt");

// After loading is complete, trace the LoadVars object.
myData.onLoad = function(success) {
trace(myData);
};


So, I get a couple errors saying can't load and can't find file even though
both files are on the same level. Is load and onLoad methods on reserved for
XML objects? What am doing wrong here? Thanks!
Motion Maker
10/7/2005 10:06:15 PM
Need to put the onLoad function before the the load method.

--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
Folder has "money.txt" and "money.fla"
Money.txt has just one variable...
&money=500

In Frame 1, of action layer, I just want to trace out in the output window
the
value of money in the money.txt. I can't even get that to work.

//Create instance of LoadVars
var myData:LoadVars = new LoadVars();

// Load Data into the LoadVars object.
myData.load("money.txt");

// After loading is complete, trace the LoadVars object.
myData.onLoad = function(success) {
trace(myData);
};


So, I get a couple errors saying can't load and can't find file even though
both files are on the same level. Is load and onLoad methods on reserved
for
XML objects? What am doing wrong here? Thanks!

FurToy
10/8/2005 8:33:44 AM
FurToy
10/8/2005 8:55:10 AM
Ok, that definitely helped. However, now I get an undefined in my dynamic text
box. At least it's a start. I'm using Jobe Makar's book FlashMX 2004
actionscript. It's 2.0 and I wouldn't think the code would be THAT different.
Now, for my Output window I get:

money=50&onLoad=%5Btype%20Function%5D

The new code is attached to this post, with your help added. Also, there's
nothing really else in the fla file other than a dynamic text box instanced
textBox_txt on another layer.

Again, any help would really be appreciated. I can't get passed the first
lesson of the book without fixing this.

//Create instance of LoadVars
var myData:LoadVars = new LoadVars();

// After loading is complete, trace the LoadVars object.
myData.onLoad = function(success) {
trace(myData);
};

// Load Data into the LoadVars object.
myData.load("money.txt");

//Output data to textBox_txt
textBox_txt.text = myData.money;
FurToy
10/8/2005 9:12:09 AM
Nevermind. Got it to work. Had to tinker with where I placed the text method.

Thanks, anyway.
~Sionna

//Create instance of LoadVars
var myData:LoadVars = new LoadVars();

//After loading is complete, trace the LoadVars object.
myData.onLoad = function(success) {
trace(myData.money);
textBox_txt.text = myData.money;

};


// Load Data into the LoadVars object.
myData.load("money.txt");
AddThis Social Bookmark Button