Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Calculate the power

New Here ,
Apr 08, 2014 Apr 08, 2014

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

                                                              

                               }

                }

}

TOPICS
ActionScript
622
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 08, 2014 Apr 08, 2014

is U1A7_ etc your document class?

any error messages?

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

Translate
Community Expert ,
Apr 08, 2014 Apr 08, 2014

is U1A7_ etc your document class?

any error messages?

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2014 Apr 08, 2014

yes U1A7_.. is my class.

and there is no error.

tks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 08, 2014 Apr 08, 2014

what did the trace show?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2014 Apr 08, 2014

unfortunatly, nothing in the output window.

What does it mean ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 08, 2014 Apr 08, 2014

it means you're not clicking btnCaluler.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 08, 2014 Apr 08, 2014
LATEST

Is not this line:

addChild(maReponse);

supposed to be:

addChild(afficheReponse);?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines