Archive for the ‘Uncategorized’ Category

Searching Array using Array.indexOf() function

Searching in Array using Array.indexOf() function is very easy . For example,
var toys:Array = new Array();
toys.push(“ball”);
toys.push(“bat”);
toys.push(“glows”);
toys.push(“pads”);
toys.push(23);
toys.push(14);
var searchIndex:int = toys.indexOf(“ball”);
if(searchIndex == -1)
{
trace(“No! how can it be there”);
}
else
{
trace(“Yup! it’s there”); //output will be from here
}
So, it works fine when the value inside the indexed array is primitive – i.e. Number, String, Boolean [...]

Continue reading »

Loading Image using Loader.loadBytes()

Loader class can load image from ByteArray. I used this method before a year ago to set  a part of a screen for Screen Sharing application. Right now I was having a case where I need to create an image from Base64 encoded string. I am using following code to do this ::
var str:String = [...]

Continue reading »