Skip to main content
Known Participant
April 8, 2014
Answered

Calculate the power

  • April 8, 2014
  • 3 replies
  • 672 views

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);

                                                              

                               }

                }

}

This topic has been closed for replies.
Correct answer kglad

is U1A7_ etc your document class?

any error messages?

put a trace in calculPuissance to see if it's being called.

3 replies

Inspiring
April 9, 2014

Is not this line:

addChild(maReponse);

supposed to be:

addChild(afficheReponse);?

ORDIYOHAuthor
Known Participant
April 8, 2014

yes U1A7_.. is my class.

and there is no error.

tks.

kglad
Community Expert
Community Expert
April 8, 2014

what did the trace show?

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 8, 2014

is U1A7_ etc your document class?

any error messages?

put a trace in calculPuissance to see if it's being called.