Ted Patrick > { Events & Community } > Adobe Systems


Strings as an array

One of the features of python is the ability to treat strings as an array. As this would be useful in AS so I wrote an addition to the string class to handle this functionality via __resolve.

Here is some sample usage:

//Test Cases
myString = "Hello World"
trace(myString) //Hello World
trace(myString[0]) //H
trace(myString[1]) //e
trace(myString[-1]) //d
trace(myString[-4]) //o
trace(myString['0:7']) //Hello W
trace(myString['1:8']) //ello Wo
trace(myString['2:9']) //llo Wor
trace(myString['6:']) //World
trace(myString[':5']) //Hello

**WARNING - This distorts inheritance, use with caution.
**Any patches to address this issue would be most welcome.

Download the Sample

Cheers,

Ted

0 Responses to “ Strings as an array ”

Post a Comment



© 2008 Ted On Flash