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

Using: if TextboxA > TextboxB make image visable

Community Beginner ,
Mar 30, 2017 Mar 30, 2017

The idea below is that if the score of Player 1 is higher than Player 2, then it is meant to show the winner image (unless the value is the same). I should note that the image is made invisible by another function already. It will work sometimes but not others. Can someone please help?

Thanks!

//Variable

var nAddPP1:Number=0;

var nAddPP2:Number=0;

//Functions

  

function fWinner(evt:MouseEvent):void{

            nAddPP1= Number(TXT_Output1.text);

            nAddPP2= Number(TXT_Output2.text);

       

        if (nAddPP2 >= nAddPP1){

           mcWinner2.visible = true;}

           

        if (nAddPP1 >= nAddPP2){

           mcWinner1.visible = true;}

         if (nAddPP1 == nAddPP2){

           mcDraw.visible = true;} 

}

bBTN_Click.addEventListener(MouseEvent.CLICK, fWinner);

TOPICS
ActionScript
223
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 ,
Mar 31, 2017 Mar 31, 2017

First try getting rid of the unnecessary evaluations and insure only one can condition be true.

//Variable

var nAddPP1:Number=0;

var nAddPP2:Number=0;

//Functions

  

function fWinner(evt:MouseEvent):void{

            nAddPP1= Number(TXT_Output1.text);

            nAddPP2= Number(TXT_Output2.text);

       

        if (nAddPP2 > nAddPP1){

           mcWinner2.visible = true;

        } else if (nAddPP1 > nAddPP2){

           mcWinner1.visible = true;

        } else {

           mcDraw.visible = true;

        } 

}

bBTN_Click.addEventListener(MouseEvent.CLICK, fWinner);

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 Beginner ,
Apr 03, 2017 Apr 03, 2017
LATEST

This works more frequently, however the winner image does appear incorrect at times and other time does not appear at all;

Apologies for the inconsistent etiquette.

Red = Identify Winner Code

Blue = Reset Values Code

Both Sets of code are on a different layer.

var nAddPP1:Number=0;

var nAddPP2:Number=0;

//Functions

function fWinner(evt:MouseEvent):void{

            nAddPP1= Number(TXT_Output2.text);

            nAddPP2= Number(tTXT_Output2.text);

      

  

        if (nAddPP2 > nAddPP1){

          mcWinner2.visible = true;}

          

        else if (nAddPP1 > nAddPP2){

          mcWinner1.visible = true;}        

}

      

//Event Listeners          

bBTN_Click.addEventListener (MouseEvent.CLICK,fWinner);

function fReset(evt:MouseEvent):void{

            TXT_Output.text = ""

            TXT_Output.text == ""

            tTXT_Output.text = ""

            tTXT_Output.text == ""

   

            BTN_Reset.visible = false;

            bBTN_Click.visible = false;

            BTN_Click.visible = true;

            mcWinner2.visible = false;

            mcWinner1.visible = false;

            MC_Card5.visible = false;

            MC_Card4.visible = false;

            MC_Card3.visible = false;

            MC_Card2.visible = false;

            MC_Card1.visible = false;

            MC_Card5a.visible = false;

            MC_Card4a.visible = false;

            MC_Card3a.visible = false;

            MC_Card2a.visible = false;

            MC_Card1a.visible = false;

            TXT_Output2.visible = false;

            TXT_Output3.visible = false;

            mMC_Card5.visible = false;

            mMC_Card4.visible = false;

            mMC_Card3.visible = false;

            mMC_Card2.visible = false;

            mMC_Card1.visible = false;

            mMC_Card5a.visible = false;

            mMC_Card4a.visible = false;

            mMC_Card3a.visible = false;

            mMC_Card2a.visible = false;

            mMC_Card1a.visible = false;

            tTXT_Output2.visible = false;

            tTXT_Output3.visible = false;

            mcWinner2.visible = false;

            mc_ReRace.visible = false;

}

BTN_Reset.addEventListener (MouseEvent.CLICK,fReset);

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