Archive for Flash Action Scripting
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
This is our First post for anyone who wann to attain good knowledge of Array used in Flash
Step1: We will tell you how the Arrays work in Flash Scripting First you have to create a object of Class Array
var student = new Array();
Step 2: Adding a Element to Array
student.push({name : “yogesh”, age : 22, marks : 125})
Step 3: Reading the Element in Array
for(i=0; i<student.length; i++)
{
trace(student[i].name + “,” + student[i].age + “,” + student[i].marks);
//trace(“\r”);
}
Step 4: Sorting Array
student.sortOn(“marks”,Array.NUMERIC);
this is used to sort the array for a numeric Value
if you wann to sort for String
student.sortOn(“name”);
If you any Queries please Respond back
We will post the latest updates ASAP
With Regards
Vikas Solanki
vikas@doomshell.com