mardi 20 septembre 2016

searchbox as3 not working properly

im having a problem where whatever text or even blank space i put i still go in frame 170, as you see i put 171 frame there, and if i type "therefore" it go in 171 , seems like its working fine its just even i put wrong text it go to frame 170 , i cant find the problem tho,also i dont know if i should make an else statement so if the word is not in the list it will go to other frame, thanks mate

 var i:int = 0;
var names:Array = new Array("therefore","disciples","nations","baptizing","father","son","holy spirit");
var frames:Array = new Array("171","170","170","170","170","170","170","170");

button_140.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_4);

function fl_MouseClickHandler_4(event:MouseEvent):void
{
var searchtext:String = searchtext.text.toLowerCase();
findInArray(searchtext);
gotoAndStop(frames[i]);
}

function findInArray(str:String):int
{
for(i=0; i < names.length; i++)
{

        if(names[i] == str)
        {
    return i;
}
}
return 0;
}

Aucun commentaire:

Enregistrer un commentaire