Home page Home page
 

This Article is for those who dont have knowledge of String Class in flash. In this Post you will see the Use of many built in functions of String class.

1. charAt()

This function is used to find the character at a particular location in the String

var mystring = new String();
mystring = “my name is sunny”
var myarray = mystring.charAt(“4″)
trace(myarray);

The result of the trace isĀ  “a” as the array start from subscript 0.

2.charCodeAt ()

var mystring = new String();
mystring = “my name is sunny”
var myarray = mystring.charCodeAt(“s”)
trace(myarray);

this Function will Give the Subscript for the character first occurance “8″

3.concat()

var string1 = new String();
string1 = “jaipur”
var string2 = new String();
string2 = “garden”
var string3 = new String();
string3 = string1.concat(” “,string2)
trace(string3);

This is used for concating two Strings

4.substr()

var string1 = new String();
string1 = “jaipur garden”
string2 = string1.substr(-6,6)
trace(string2);

in this Function there are two parameter the first with negative symbol will counts the character from end and the next is number of character.

5.toLowerCase()

var string1 = new String();
string1 = “INDIA IS GREAT”
trace(string1.toLowerCase());

This function is used for converting the string to lowercase

6.split()

var myString=new String();
myString=”ali-bili-cat-dog”;
var myArray=new Array();

myArray=myString.split(“-”);

for(i=0;i<myArray.length;i++)
{
trace(myArray[i]);
}

This function is used for seprating a string into array elements based on specific seprating creteria

With Regards

Vikas Solanki

www.doomshell.com

Comments