This content has been marked as final. Show 2 replies
> I may be confused, but I thought you could use
> array access notation with strings.
It's made for objects, actually. The array access operator, , allows
you to access elements from an Array instance and also lets you access
properties from any sort of object. The "trick" it provides, in this latter
case, is that you can refer to these properties -- within the brackets --
with strings, so it's often used to reference objects dynamically.
> var sWorkingText:String = tText.text;
Here you've declared a String variable and set it to the TextField.text
property of some textfield. So far, so good.
> var sNewText:String = oPhotoText[sPageFocus];
Here, you've declared a String variable, but it seems that you're
setting it to a property of the oPhotoText object. That's now how this
The array access operator allows you to *use* strings to get at an
// functionally equivalent
someObject["property" + 1];
var x:Number = 1;
someObject["property" + x];
Does that help?
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."
Nope you cannot use array acces notation with strings. If you want to read a letter use the chatAt() method this way:
this example reads the a character in the nIndex index;