-
hide "undefined" message in dynamic text box
Hi, I'm loading external text using:
var externalData:LoadVars = new LoadVars();
externalData.onLoad = function(){
scopy_txt.text = externalData.shomecopy;
}
externalData.load("shomecopy.txt");
There are a few .txt files that haven't been created yet, so naturally the box reads "undefined". However, in the files that are loading, I'm still getting an "undefined" message before the actual text shows up. How can I hide/prevent this?
I tried: if (scopy_txt.text = "undefined"){
scopy_txt.text.setVisible(false);
} else{ scopy_txt.text.setVisible(true);
}
and it didn't work
here's the site:
http://www.surroundings-rogersgallery.com/
-
Senior Member
When declaring a variable you say =
When requesting a variable you say ==
_root.scopy_txt="text"
_root.scopy_txt=="text"
change your script to
if (scopy_txt.text == "undefined"){
scopy_txt.text.setVisible(false);
} else{ scopy_txt.text.setVisible(true);
}
Hope it helps
-
Thanks for the help, but that didn't work either.
-
Senior Member
Try undefined without "". Undefined is not a string.
/Per-Henrik
-
no go, it's still flashing "undefined" before loading the text.
-
Uses MX 2004 Pro
You can use a boolean variable to determine if the text is loaded and display the text if it's there, or nothing at all if the load fails.
Code:
var externalData:LoadVars = new LoadVars();
externalData.onLoad = function(success:Boolean) {
if (success) {
scopy_txt.text = this.shomecopy;
}
};
externalData.load("shomecopy.txt");
-
It seems to work for the main movie text - when you first come to the scene, but not for the .txt files loaded from the external swfs.
My external swf's have three frames (first two for preloader) and the third loads the external text:
this.onEnterFrame = function(){
_root.scopy_txt.text = _root.externalData.sbathcopy;
}
_root.externalData.load("sbathcopy.txt");
should I be adding a Boolean here here also?
-
Uses MX 2004 Pro
Originally Posted by lotsamottsa
It seems to work for the main movie text - when you first come to the scene, but not for the .txt files loaded from the external swfs.
My external swf's have three frames (first two for preloader) and the third loads the external text:
this.onEnterFrame = function(){
_root.scopy_txt.text = _root.externalData.sbathcopy;
}
_root.externalData.load("sbathcopy.txt");
should I be adding a Boolean here here also?
Yes, you'd need to use it for each time you load in a text file. Out of curiosity, why are you using an onEnterFrame event handler in your above post, and not .onLoad?
-
a way i have got round this before is by setting a default loading value into the text area like for example "loading xml data", this is replaced when the loaded data becomes available.
-
yaaaayyy that worked thanks Quixx! I didn't realize I needed to repeat the whole code in each external swf. I was refering to the external swf using this.onEnterFrame because this.onLoad didn't load any text at all, but now I realize using _root.externalData.onLoad makes more sense.
Thank you so much for your help and thank you all for your time!!!
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
|