我可以使用 indexOf 在数组中进行搜索,但向量不起作用
import flash.events.KeyboardEvent;
var characters:Vector.<String > = Vector.<String > (["abcdef".split("")]);
trace(characters);
txt.restrict = characters.toString();
txt.addEventListener(KeyboardEvent.KEY_DOWN,search);
function search(event:KeyboardEvent):void
{
var i:int = characters.indexOf(String.fromCharCode(event.charCode));
trace("key press= "+String.fromCharCode(event.charCode),"indexOf search ="+i);
}
输出
a,b,c,d,e,f
key press= a indexOf search =-1