PDA

View Full Version : text to load on release?


wickedboy
07-11-2005, 07:30 PM
I have a number of dynamic txt fields embedded inside a few MCs and I'm trying to load text into them from an external txt file. The first part of the code works fine...but not when I try to load the txt on release, then no text appears...does anyone know how I could solve this problem, please?
On the frame:
myData = new LoadVars();
myData .load("anastasio2.txt");
//creating the loadVarsText function
myData .onLoad = function() {

//this is were it fails

aa.text = this.aa1;
aaa.text = this.aaa1;
ab.text = this.ab1;
};
_root.aa._visible = false;
_root.aaa._visible = false;
_root.ab._visible = false;
_root.answer4._visible = false;
_root.answer5._visible = false;

On the button:
//show me the goods
on(release){
_root.aa._visible=!aa._visible
}
and finally inside the txt:
aa1=cool
&aaa1=man
&ab1=luke

Help!

skyflower
07-11-2005, 08:49 PM
the onLoad function should check if the variables were loaded first:

myData.onLoad = function(success) {
if(success) {
aa.text = this.aa1;
aaa.text = this.aaa1;
ab.text = this.ab1;
}
};

:)

wickedboy
07-12-2005, 06:49 PM
Thanks for helping but that doesn't work... any other ideas?

skyflower
07-12-2005, 07:06 PM
oh,

I didn't notice
instead of "this" you should put "myData"

wickedboy
07-12-2005, 07:18 PM
Thanks man, didnt spot it myself!

wB

gabrielknight
07-13-2005, 02:05 PM
Ok, this is getting complicated to explain but here goes... :rolleyes:

I'm making a small app with four frames. Frame 1 - I have a form that reads data from an external txt file (this works fine) with this code on the frame with the txt fields:
stop();
//Create the LoadVars object and load data into it
myData = new LoadVars();
myData.load("anastasio2.txt");
//Make a reference to current timeline

//Callback handler and data fetching
myData.onLoad = function(){

for(i=0;i<=4;i++)
{
eval("Title_txt"+i).text = this["Title"+i];
eval("Comments_txt"+i).text = this["Comments"+i];
}
}
Frame 2 - I have the same form + another one which the data is loaded on release for each part of the form. This works great but the first form's data is not loaded on this frame...I can't get the function to work as the second one (below) is deinitialising the first somehow. Can someone please help me with this function so that all data is loaded? :o
Code for Frame 2
stop();

myData = new LoadVars();
myData .load("anastasio2.txt");
//creating the loadVarsText function
myData.onLoad = function() {
_root.aa.aa.text = this.aa1;
_root.aaa.aaa.text = this.aaa1;
_root.ab.ab.text = this.ab1;
_root.abb.abb.text = this.abb1;

};
_root.aa._visible = false;
_root.aaa._visible = false;
_root.ab._visible = false;
_root.abb._visible = false;

I would really appreciate a hand, I am stuck!

Gabs

skyflower
07-13-2005, 04:01 PM
again, you are using 'this' instead 'myData'

gabrielknight
07-13-2005, 04:13 PM
Cheers, chnaged it but the other data isn't loading still...Any idea?

skyflower
07-13-2005, 05:23 PM
I don't understand what you are referring to here:
this["Title"+i]

gabrielknight
07-13-2005, 06:09 PM
Variable that's loaded

skyflower
07-13-2005, 06:18 PM
but you are loading the variables into the myData object, I don't understand why you are referencing them by using "this"

gabrielknight
07-13-2005, 06:27 PM
I've now changed it to myData. It still doesn't load both the Title_txt/Comment.txt and the aa (etc) txt...

Idea?