Hello,
(Using Flash MX)
I’m wondering if theres a way I can turn a variable of strings (separated by commas) into an array?
I’m using the loadVars object to import variables from a text file that I’d like to import to flash as an array.
For example if the variable I import from the text file looks like this:
&myVar=charlie,dog,cat,test&
I’d like to get it into an array in Flash like this
myArray = new Array[“charlie”,“dog”,“cat”,“test”];
Is there any way to do that? :rocker:
Thanks!
system
February 14, 2004, 2:24am
2
You will need the asfunction to load the movies from the text links.
Check this:
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=42654
system
February 14, 2004, 3:30am
3
caludio - thanks thats just what I needed.
One problem though, I’m using the comma (",") as my delimiter for splitting the variable that I’m importing and when the comma shows up in this line of code:
&cats=<a href='asfunction:listing,adv'>Advertising Agencies</a>
It cuts off the asfunction - function and argument and just plain out messes up my string.
Is there another delimiter I can use besides a comma, a white space or a tab?
system
February 14, 2004, 3:52am
5
I have a better idea. It would be better to use XML, but heres an optimized version:
function loadClip(arg) {
var temp = arg.split("|");
loadMovie(temp[0], temp[1]);
}
l = new LoadVars();
l.onLoad = function(success) {
if (success) {
my_txt.html = true;
var myArray = this.myVar.split(",");
for (var i = 0; i<myArray.length; ++i) {
var parameters = myArray*.split("|");
my_txt.htmlText += "<b><font size='14'><a href='asfunction:loadClip,"+parameters[0]+".swf|"+parameters[1]+"'>"+parameters[0]+"</a></font></b>
";
}
}
};
l.load("textfile.txt");
and your textfile should hold the file name and the corresponding container movieclip:
myVar=dog|holder1,plane|holder2,cat|holder3,house|holder4&
system
February 14, 2004, 3:52am
6
Alright I’m using the # sign and that works fine.
Now I have another question :jail:
The items in the array I’m importing now look like this:
<a href='asfunction:listing,0'>Advertising Agencies</a>
I’d like to somehow turn this item from my array back into a variable without the HTML tags around it so it will just look like
Advertising Agencines
And then I’d like to break that down into just a 4 letter variable starting with the first 4 characters
adve
I know that I can use split() on the string as well as toLowerCase() on the last two items, but how can I get rid of the HTML Tag first off?
Thanks!
system
February 14, 2004, 4:08am
7
Claudio,
Thanks for your ideas they are really helping me. I owe you 2.
Foo