Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flash 当文本框中没有任何内容时,用0填充文本框_Flash_Actionscript 3 - Fatal编程技术网

Flash 当文本框中没有任何内容时,用0填充文本框

Flash 当文本框中没有任何内容时,用0填充文本框,flash,actionscript-3,Flash,Actionscript 3,我正在学习动作脚本3,如果输入文本框中没有任何内容,我需要在文本框中输入0。到目前为止,我开始的东西,但它不工作 var courage:int = parseInt(courage_txt.text); function checkTraits(e:Event){ stage.addEventListener(Event.CHANGE, checkTraits); if(courage_txt.text == ""){ courage = 0; } 我知道我错过了什么我只是不

我正在学习动作脚本3,如果输入文本框中没有任何内容,我需要在文本框中输入0。到目前为止,我开始的东西,但它不工作

var courage:int = parseInt(courage_txt.text);

function checkTraits(e:Event){

stage.addEventListener(Event.CHANGE, checkTraits);

if(courage_txt.text == ""){
    courage = 0;

}
我知道我错过了什么我只是不知道什么

试试这个

stage.addEventListener(Event.CHANGE, checkTraits);

function checkTraits(e:Event) {

     if(courage_txt.text == "") {
         courage_txt.text = "0";
     }

     courage = parseInt(courage_txt.text);
}

我知道我错过了什么!那真的很有帮助!非常感谢。