hi i have Text input a button . I want to compare the values from the textInput box with values from a array. and if the number in the box is true to start playing the video.
You can iterate over the array and compare the values to the box like this:
for (var i:int =0 ; i < myArray.length; i++){
if(textInput.text == myArray[i])
//Start playing video here
}
}
EDIT:
Now I've seen what you're trying to do (I think), here's what you need to do:
1) Add a listener to the button
2) Inside the handler function, iterate your array and check values
3) If value is same as text, then start the video
var myArray:Array = ["1","2","3"];
bbt.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame);
function fl_ClickToGoToAndPlayFromFrame(event:MouseEvent):void //starting the video
{
for (var i:int = 0; i < myArray.length; i++){
if(textInput.text == myArray[i]){
gotoAndPlay(5);
}
}
}
If you're only going to have numbers in the array, you can simplify the loop further:
for (var i:int =1 ; i < 4; i++){ //Will loop 3 times, with i equalling 1, 2, and 3
if(textInput.text == i){//Checks text directly against i, rather than array[i]
gotoAndPlay(5);
}
}