-
Still kisses with saliva
[CS3/AS2] Problem importing vars from text file
This is a repost from ellis001's RESOLVED thread. I didn't think anyone would open the RESOLVED thread.
I'm trying to do almost exactly the same thing as ellis001, but I'm still getting (undefined). When I trace the variable that's being split into the array, it returns: <p align="left"></p>
My text file is MEname9.txt and contains:
&MEnames=1,2,3,4
The code I have currently for this section is:
var photoNum = 0;
var NameLoader = new LoadVars();
NameLoader.onLoad = function(success){
NameArray = new Array();
if (success){
MEnames = NameLoader.MEnames;
NameArray = MEnames.split(",");
}
}
NameLoader.load("MEname9.txt");
trace(MEnames);
NameBox.text = NameArray[photoNum];
It's identical to what a_modified_dog posted, and I can't see any difference in what I'm doing vs. what ellis001 was trying to do as far as importing the text and putting it into an array. But the array just isn't working. Any advice?
a pig
in a cage
on antibiotics
-
PHP Code:
var NameLoader = new LoadVars();
NameLoader.onLoad = function(success){
NameArray = new Array();
if (success){
MEnames = NameLoader.MEnames;
trace(MEnames);
NameArray = MEnames.split(",");
NameBox.text = NameArray[photoNum];// Whatever photoNum is?
}
}
NameLoader.load("MEname9.txt");
-
Still kisses with saliva
Wow, thanks, sstalder! That gets the array working!
I want NameArray to show the next element everytime photoNum advances (I set photoNum to 0 in this frame and have it advance in another movie clip). I guess that's my next hurdle in getting this to work. Thanks again!
a pig
in a cage
on antibiotics
-
Sounds good. If you will notice that you have to run everything inside that load function, or once the text file is loaded into memory (which is why I only moved your code into the onLoad function to get it working).
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
|