Share on Google+Share on Google+

String in Action Script3

String is a sequence of letters, numbers and other characters binding together in a single value.

String in Action Script3:-

String is a sequence of letters, numbers and other characters binding together in a single value. String Class is a data type, we have created a variable that have String data type and assign a literal string value in that variable. If user want to work with textual value then it can be use String class in Action Script3. In the Action Script3 , the string value represented in the double or single quotation marks.


<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx=""


xmlns:mx="library://" creationComplete="init();">



private function init():void{

var str:String = "This is string.";

myText1.text = str;

str = "This is another String.";

myText2.text = str;




<s:Panel width="200" height="200" title="String Class Panel" backgroundColor="0x81B5AA">


<mx:Text id="myText1"/>

<mx:Text id="myText2"/>




In this example, we have created a variable that have String data type. It means that accept only string value. we have put a string literal as " This is string."  and set these string value in the Flex Text control that's display these value. In this example, we have discuss about how to create a string data type or String class object in Action Script3.


Download this code

String Class in Action Script3
String class is a data type. String class provides methods for access and manipulation of textual value.
String length property example
If user want to find out number of characters in a string. In this case String has a length property that return the number of characters in the specified String object.
Find Character form String example
String maintain a index position for every character in the string. The first character index position is 0.
String fromCharCode() method example in Action Script3
String provide a method to find characters by the character code using fromCharCode() method.
Object representation in to String example
We can represent any kind of object in the form of string. For this purpose we have used toString() method for any kind of object.
String concatenation process example
In the Action Script3, String is uses "+" operator for concatenate two strings.
String toLowerCase and toUppercase methods example
String class provides methods toUpperCase() and toLowerCase().
String substring method example
In the Action Script3, substring are sequential characters that are found from a string. String class provide methods for finding substring from string.
String substr method example
This method takes two integer parameters, first is starting character position and second is length of the substring.
String slice method example
The string slice() and substring() methods functionality is same but difference is that slice() can take negative integer parameters.
String indexOf method example
String class method indexOf() is use to find the starting character position of the substring from the string.
String comparison example
There are many comparison operators for comparing strings like <, <=, !=, ==, =>, and >.


Posted on: June 3, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null