Flash CS4, Inactive buttons

ぃ、小莉子 提交于 2019-12-13 02:24:45

问题


I have no syntax errors when I run this code. I checked the variables and the functions in the action panel and it works fine. But, when I remove the codes from the action panel, and try to run the .as file nothing happens when I click the button. Here's my code:

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:


I think that your have just to add your U1A4_Sommeil class as your document class using your document properties :

Or, from File Menu > ActionScript Settings... then :

Hope that can help.



来源:https://stackoverflow.com/questions/28748305/flash-cs4-inactive-buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!