Stuff I am building:


Ted Patrick - Events & Community @ Adobe Systems


Note: This is the personal blog of Ted Patrick. The opinions and statements voiced here are my own.



Strings as an array

DIGG IT!     0 Comments Published Wednesday, September 24, 2003 at 9:39 AM .

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

Where to find me:

Ted on Twitter - @AdobeTed
Ted on Adobe Groups
Ted on LinkedIn
Ted on Facebook
Ted at Adobe


Latest

Lists

Links

Jobs

Flex Jobs
city, state, zip

Archives