Copy link to clipboard
Copied
HI there, this is my program. I'm trying to calculate the power of a number entered first but when i click on the button, nothing happens.
Helps pls.
Tks a lot.
package
{
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class U1A7_Puissances extends MovieClip
{
public var entierBase:TextField;
public var entierExposant:TextField;
public var btnCalculer:SimpleButton;
private var maMiseEnForme:TextFormat=new TextFormat();
private var afficheReponse:TextField=new TextField();
public function U1A7_Puissances()
{
this.btnCalculer.addEventListener(MouseEvent.CLICK, this.calculPuissance);
}
private function calculPuissance(event:MouseEvent):void
{
var intBase:int = 0;
var intExposant:int = 0;
var nouvMessage:String= "";
var i:int=0;
intBase = int(this.entierBase.text);
intExposant = int(this.entierExposant.text);
while (i++ < intExposant)
{
nouvMessage=(nouvMessage + intBase + " exposant " + i + " = " + Math.pow(intBase,i) + "\n");
}
maMiseEnForme.font="Arial";
maMiseEnForme.size=20;
maMiseEnForme.color=0x0000FF;
afficheReponse.defaultTextFormat=maMiseEnForme;
afficheReponse.x=50;
afficheReponse.y=50;
afficheReponse.border=true;
afficheReponse.borderColor=0x000000;
afficheReponse.autoSize=TextFieldAutoSize.LEFT;
afficheReponse.text = nouvMessage ;
addChild(maReponse);
}
}
}
is U1A7_ etc your document class?
any error messages?
put a trace in calculPuissance to see if it's being called.
Copy link to clipboard
Copied
is U1A7_ etc your document class?
any error messages?
put a trace in calculPuissance to see if it's being called.
Copy link to clipboard
Copied
yes U1A7_.. is my class.
and there is no error.
tks.
Copy link to clipboard
Copied
what did the trace show?
Copy link to clipboard
Copied
unfortunatly, nothing in the output window.
What does it mean ?
Copy link to clipboard
Copied
it means you're not clicking btnCaluler.
Copy link to clipboard
Copied
Is not this line:
addChild(maReponse);
supposed to be:
addChild(afficheReponse);?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now