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

comparation operator in flash canvas

Participant ,
Jan 10, 2017 Jan 10, 2017

Copy link to clipboard

Copied

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

Views

252

Translate

Translate

Report

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

LEGEND , Jan 11, 2017 Jan 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

...

Votes

Translate

Translate
LEGEND ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
Participant ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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 ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Participant ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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 ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

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