Skip to main content
Inspiring
January 11, 2017
Answered

comparation operator in flash canvas

  • January 11, 2017
  • 1 reply
  • 383 views

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

    This topic has been closed for replies.
    Correct answer Colin Holgate

    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.

    1 reply

    Colin Holgate
    Colin HolgateCorrect answer
    Inspiring
    January 11, 2017

    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.

    Inspiring
    January 11, 2017

    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!

    Colin Holgate
    Inspiring
    January 11, 2017

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