Flash CS4,非活动按钮

时间:2015-02-26 16:59:31

标签: actionscript-3 flash button adobe flash-cs4

运行此代码时,我没有语法错误。我检查了操作面板中的变量和函数,它工作正常。但是,当我从操作面板中删除代码,并尝试运行.as文件时,单击按钮时没有任何反应。 这是我的代码:

package
{
import flash.display.*;
import flash.events.MouseEvent;
import flash.text.*;
import flash.display.MovieClip; 



public class U1A4_Sommeil extends MovieClip
{
private var monMessage:TextField = new TextField;
private var maMiseEnForme: TextFormat = new TextFormat;
public function U1A4_Sommeil ()
{
btnSoumettre.addEventListener(MouseEvent.CLICK,Calcule);
}

private function Calcule (event:MouseEvent):void
{
maMiseEnForme.font= "Arial";
maMiseEnForme.size = 20;
maMiseEnForme.color = 0xFF0000;
maMiseEnForme.bold = true;

monMessage.autoSize = TextFieldAutoSize.LEFT;
monMessage.defaultTextFormat = maMiseEnForme;
monMessage.x = 260;
monMessage.y = 260;
monMessage.border = true;

var intAn : int = int(txtAn.text) - int(txtAnNaissance.text);
var intMois : int = int(txtMois.text) - int(txtMoisNaissance.text);
var intJour : int = int(txtJour.text) - int(txtJourNaissance.text);

var strResultat : String = ("Tu es agé de "+ (intAn*365+intMois*30+intJour) + " jours." 
+ "\n" 
+ "Tu as dormi " + ((intAn*365 + intMois*30 + intJour)*8) + " heures"
+ "\n"
+ "depuis ta naissance.");
monMessage.text = strResultat;
addChild (monMessage);
    }
}
}

1 个答案:

答案 0 :(得分:0)

我认为您只需使用文档属性将U1A4_Sommeil类添加为文档类:

enter image description here

或者,从文件菜单> ActionScript设置... 然后:

enter image description here

希望可以提供帮助。