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 [...]
Archive for April, 2009
21 Apr
Searching Array using Array.indexOf() function
17 Apr
Set TextField horizontal scroll to initial position
If you want to set the position of horizontal scroll position inside TextField, you can use TextField.scrollH.
Let’s say I am typing in the input TextField and I typed beyond the width of TextField. You will see the last characters visible you typed. Now due to some other event, say user clicks on other than this [...]
8 Apr
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 = [...]
8 Apr
Built-In Context Menu Items on Flash TextField
Is there any way to hide default context menu items on Flash TextField? Some one will try to answer with ContextMenu.hideBuiltInItems() function, but this function does not really work with Flash TextField. It does not hide the built in items.
So following code does work but not as expected ::
var myContextMenu:ContextMenu = new ContextMenu();
myContextMenu.hideBuiltInItems();
var txt:TextField = [...]
Recent Comments