![](/img/trans.png)
[英]Flash CS5 Actionscript 3.0 Using a movie clip as a button with linking
[英]how to check input text using ActionScript 3 with movie clip button?
我剛剛開始我的新項目。 所有我需要的是,我想使用按鈕檢查輸入文本,如果輸入文本框上的值等於1,跟蹤(“真”),否則跟蹤(“假”)。
這是示例鏈接http://localhostr.com/file/P2Q3bpn/test.fla
問題是,當我試圖將文本輸入1時,它總是轉到其他地方,這意味着錯誤。 也都是數字。 對不起,我的英語不好。 這就是我做的
var check:Boolean = false;
var input1:String;
var answer:String = "1";
MCButton.addEventListener(MouseEvent.CLICK, checkClick);
function checkClick(event:MouseEvent):void{
input1= inputBox.text;
check = true;
if(input1 == answer){
trace("true");
}
else trace("false");
}
謝謝
如果您的答案始終是數字,請嘗試以下方法:
if(parseInt(input1) == parseInt(answer))
{
...
...
...
}
實際上你打開了“多線”。 所以你得到的是“1 \\ n”,其中“\\ n”是“新行”。 這不等於“1”。 關閉多線,它會沒問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.