开发者

flash as2 textfield - enter key issue

I have a search box in my flash file and I'm trying to have it execute a getURL() when the enter key is pressed inside the text field, but nothing is happening. Can someone let me know what the issue is?

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, "_b开发者_如何学运维lank");
}

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");
    }
};


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜