5 Replies Latest reply on Jan 11, 2017 1:38 PM by Colin Holgate

    comparation operator in flash canvas

    cbunbury20 Level 1

      I am trying to get back to flash so i am trying to convert some of my old flash games to it, but having a hard time,

       

      http://fotografiaramces.com/flash/memomex1.html

      http://fotografiaramces.com/flash/memomex1.html

       

      when the animation of card finish the variable is set to 1 so it should only play the anim for the card once i am trying this

       

      this.huerta1_mc.addEventListener("click", fl_MouseClickHandler_2.bind(this));

       

       

      function fl_MouseClickHandler_2()

      {

        if(this.huerta1 == 0){

        alert(huerta1);

        this.huerta1_mc.gotoAndPlay(2)

        }

       

      }

       

      but its not working i can trigger the anim every time, and the alert wont show up, i checked for animate operators unsucesfully

       

      here is the fla http://fotografiaramces.com/flash/memomex1.fla

       

      I eagerlly want to comeback to flash, since construct2 or buildbox just dont fell the same but if i cant perform a little simple comparing operation to manipulate movie clips its sad.

       

      tyvm and happy new year

        • 1. Re: comparation operator in flash canvas
          Colin Holgate MVP & Adobe Community Professional

          You should be playing from frame 1, not 2. In HTML5 Canvas frames start at 0. That isn't part of your main problem, but it will make the card turn look better.

           

          You have these in the main timeline:

           

          var huerta1 = 0

          var huerta2 = 0

          var villa1 = 0

          var villa2 = 0

           

          which I believe only assigns them to the frame that they are declared on. You can make them valid across all the main timeline frames with:

           

          this.huerta1 = 0

          this.huerta2 = 0

          this.villa1 = 0

          this.villa2 = 0

           

          When you set them to 1 you are doing that in a sub movieclip (the actual card):

           

          this.huerta1 = 1;

           

          but really you want to set the variable in the main timeline, which this should do:

           

          this.parent.huerta1 = 1;

           

          Also, look at what is put into the Output panel when you do a test, some of those errors might be important.

          • 2. Re: comparation operator in flash canvas
            cbunbury20 Level 1

            Good mourning and ty so much

             

            I try this:

             

            this.huerta1_mc.addEventListener("click", fl_MouseClickHandler_2.bind(this));

             

             

            function fl_MouseClickHandler_2()

            {

              if(parent.huerta1 == 0){

              alert(huerta1)

              alert(raiz.huerta1)

              this.huerta1_mc.gotoAndPlay(1)

              }

            }

             

            but it wont play or alert's wont execute, i using "raiz" as your self hack(for _root) for the root thing but now card wont play, if i remove the if statement it would play fine but it would replay every clic, even if i remove all statements and leave just the alerts they wont execute!i thank you so much for your time and awesome website and works you got!

            • 3. Re: comparation operator in flash canvas
              Colin Holgate MVP & Adobe Community Professional

              You would have to say  if(this.parent.huerta1 == 0){

              • 4. Re: comparation operator in flash canvas
                cbunbury20 Level 1

                ok my bad, i guess i am not hitting, the target, lol tellTarget right, for variables has

                 

                var huerta2 = 0

                 

                the alert would stop executing, and with the parent i just got undefines, so i try with new variable declare as old as2 style:

                 

                huerta3 = 0 and then it all work

                 

                 

                 

                this.huerta1_mc.addEventListener("click", fl_MouseClickHandler_22.bind(this));

                function fl_MouseClickHandler_22()

                {

                 

                  alert(huerta1)

                 

                  if(huerta1 == 0){

                  this.huerta1_mc.gotoAndPlay(1)

                  }

                 

                }

                 

                thank you very much i can almost fell the ashes rising from my old good AS2 times, have a great day

                • 5. Re: comparation operator in flash canvas
                  Colin Holgate MVP & Adobe Community Professional

                  Your solution works because it became a window or document variable, and should be readable from everywhere. Just make sure not to use the same name for two different purposes.