|
-
Very simple function, variable are not setting!
Hi, this is infuriating me.
I have the below function which works with
Code:
function loadText(){
textImport = new LoadVars();
textImport.onLoad = onText;
textImport.load("content.txt");
function onText() {
textBox.htmlText = textImport.aboutUs;
}
}
But when i set a variable like below it doesnt work. The text box comes back as "undefined". Ultimately i want to pass through some arguments through the function, but i just cant work out why its not passing through this variable. Iv tryed single quotes, double quotes and no luck!
Code:
function loadText(){
var jgm = aboutUs;
textImport = new LoadVars();
textImport.onLoad = onText;
textImport.load("content.txt");
function onText() {
textBox.htmlText = textImport.jgm;
}
}
Thanks for your time and any help greatly appreciated.
-
OOP is one letter from OOPS
LoadVars variables are defined in the file being loaded as:
varName=varValue&varName2=someOtherValue
the var you declared:
var jgm
is not eqivelent to
textImport.jgm
unless you defined it
textImport.jgm = aboutUs
but then there is no point using LoadVars and the variable is being defined iunternally anyway.
Now if aboutUs is some variable that is being loaded, you are trying to access it too early. You would have to access it after the load completed as in:
function onText() {
textImport.jgm = textImport.aboutUs
textBox.htmlText = textImport.jgm;
}
but at that point why bother when you could just:
function onText() {
textBox.htmlText = textImport.aboutUs;
}
So it might just be that I am not totaly understanding what you are trying to do with this.
-
Flashmatics
that because jgm is not being set after the variables have been loaded. u are trying to assign aboutUs to jgm before.. modify you code:
Code:
function loadText(){
textImport = new LoadVars();
textImport.onLoad = onText;
textImport.load("content.txt");
function onText() {
this.jgm = this.aboutUs;
textBox.htmlText = this.jgm;
}
}
P.S what r u trying to do anyway? The first function looks fine for your needs...
-
Im still getting an "undefined" message.
P.S what r u trying to do anyway?
The function is there to load different parts of the text file for different sections of the site. I want to pass through a variable that has the name of the part in the text file the example i am trying below has the variable "aboutUs".
This code is on the first keyframe of the movieclip.
Code:
function loadText(path){
textImport = new LoadVars();
textImport.onLoad = onText;
textImport.load("content.txt");
function onText() {
this.jgm = this.path;
textBox.htmlText = this.jgm;
}
}
Then the below is on a keyframe further up the timeline within the same movie clip.
Code:
loadText("aboutUs");
Thanks.
Last edited by juanmac; 06-30-2006 at 10:17 AM.
-
OOP is one letter from OOPS
What does the text file you are loading look like?
-
Its like this:
Code:
aboutUs=<p>PMS is an Aberdeen based dynamic and creat............</p>
&aboutUs2=<p>Producers, editors, animators, cameramen all bring their own specific talents................</p>
-
OOP is one letter from OOPS
see if :
function onText() {
textBox.htmlText = this[path];
}
works. Might be messing up because you are passing the function a string when trying to access a variable name.
-
Thats working. FANTASTIC!
Thanks very much!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|