我的flash文件中有一个搜索框,当我在文本字段中按下回车键时,我试图让它执行getURL(),但什么也没发生。有人能告诉我这是什么问题吗?
this.createTextField("dynamic_txt", 1, 115, 9, 138, 22);
dynamic_txt.type = "input";
dynamic_txt.multiline = false;
dynamic_txt.wordWrap = false;
var my_fmt:TextFormat = new TextFormat();
my_fmt.font = "Arial";
my_fmt.size = 12;
my_fmt.color = 0x000000;
my_fmt.underline = false;
dynamic_txt.text = "This is my first test field object text.";
dynamic_txt.setTextFormat(my_fmt);
button_search.onRelease=function(){
trace("Search Button");
getURL("http://www.website.com/?s="+dynamic_txt.text, "_blank");
}
dynamic_txt.onKeyDown = function() {
trace("Pressed Enter");
if (Key.isDown(Key.ENTER)) {
trace("You Pressed Enter");
getURL("http://www.website.com/?s="+dynamic_txt.text, "_blank");
}
};
答案 0 :(得分:0)
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
// trace("Pressed Enter");
if (Key.isDown(Key.ENTER)) {
trace("You Pressed Enter");
getURL("http://www.website.com/?s="+dynamic_txt.text, "_blank");
}
};
Key.addListener(keyListener);