all groups > flash actionscript > september 2004 >
You're in the

flash actionscript

group:

Strings and createTextField


Strings and createTextField mrmille
9/27/2004 9:50:25 PM
flash actionscript:
In the code listed below i define a comma separated text string wich i split
using the split funtion

What i want to do is to create a textfield dynamicly for each and one of the
objects that i get of in the array.
The array splits them up and delivers them like
Best
Firebee
Flexifoil
And so on...

The script generates no error but does not show any text either.
I assume that i should declare the "var fName = "tx" + dVendors" in some way
but dont know how.

Is it even possible to generate theese textfields from an array?
It should be since the createEmptyMovieClip works just fine with the same type
of code.

Please help!
Eric

var str:String = "Best,Firebee,Flexifoil,Flysurfer,Naish,Ozone,Slingshot";

var dVendors:Array = str.split(",");
for (var i = 0; i<dVendors.length; i++) {
// trace(dVendors[i]);

var fName = "tx" + dVendors[i]
_root.createTextField("" + fName + "", 10, 0, 0, 100, 25);
fName.wordWrap = true;
fName.autoSize = true;
fName.text = dVendors[i];
trace(fName);
}
Re: Strings and createTextField _jrh_
9/27/2004 9:55:01 PM
Two things. Your text field names look like they're all the same (probably not
because you have an i in there somewhere, but it makes things italic so you
can't tell). Also, all the depths are the same, which erases whatever was on
that depth. Try this instead:

_root.createTextField("Name"+k, 10+k, (i*15), 0, 100, 25);
fName = _root["Name"+k];

Where 'k' is your 'i'.

Re: Strings and createTextField mrmille
9/28/2004 8:14:51 AM
Thanks _jrh_ but that wasn't the right one.
I've figured it out anyway and post the code below if someone wants to see.

Good luck to all of ya!

var str:String =
"Best,1,Firebee,2,Flexifoil,3,Flysurfer,4,Naish,5,Ozone,6,Slingshot,7";

var dVendors:Array = str.split(",");
for (var i = 0; i<dVendors.length; i++) {

_root.createTextField(dVendors[i], 10+i, 10, (i*15)/2, 100, 25);

var fName = new String("tx" + dVendors[i]);

eval(dVendors[i]).autoSize = true;
eval(dVendors[i]).selectable = false;
eval(dVendors[i]).htmlText = dVendors[i] + " ?";
i++;
}
AddThis Social Bookmark Button