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

not an object error

Contributor ,
Nov 10, 2017 Nov 10, 2017

In this code, a checkmark appears when each button is clicked. When all 3 buttons are clicked I want the continue arrow to appear. It is on stage, but invisible. I get an error "TypeError: undefined is not an object (evaluating 'this.continueArrow.visible = true')".

this.atmosphere_but.addEventListener("click", fl_ClickToGoToAndStopFromFrame208.bind(this));  var checks = 0;  function checkChecks() {      //alert(checks);      if (checks >=3) {            this.continueArrow.visible = true;        } }  function fl_ClickToGoToAndStopFromFrame208() {      this.gotoAndStop(208);      this.check1.visible = true;      checks = checks+1;      checkChecks();       }   this.crust_but.addEventListener("click", fl_ClickToGoToAndStopFromFrame209.bind(this));  function fl_ClickToGoToAndStopFromFrame209() {      this.gotoAndStop(209);      this.check2.visible = true;      checks = checks+1;      checkChecks(); }   this.mantle_but.addEventListener("click", fl_ClickToGoToAndStopFromFrame210.bind(this));  function fl_ClickToGoToAndStopFromFrame210() {      this.gotoAndStop(210);      this.check3.visible = true;      checks = checks+1;      checkChecks(); }  
307
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 , Nov 10, 2017 Nov 10, 2017

"this" isn't defined in checkChecks().

ie, pass a reference from your other functions where it is defined or define a variable that can be used in checkChecks.  the former:

function checkChecks(this_var){

//now use "this_var" instead of "this"

}

function yourotherfunctions(){

.

.

checkChecks(this);

}

////////////////////////

the later:

var this_var=this;

function checkChecks(){

//now use "this_var" instead of "this"

}

Translate
Community Expert ,
Nov 10, 2017 Nov 10, 2017

"this" isn't defined in checkChecks().

ie, pass a reference from your other functions where it is defined or define a variable that can be used in checkChecks.  the former:

function checkChecks(this_var){

//now use "this_var" instead of "this"

}

function yourotherfunctions(){

.

.

checkChecks(this);

}

////////////////////////

the later:

var this_var=this;

function checkChecks(){

//now use "this_var" instead of "this"

}

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
Contributor ,
Nov 10, 2017 Nov 10, 2017

that worked perfectly. thanks kglad! I'd have never figure that out.

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 ,
Nov 10, 2017 Nov 10, 2017

you're welcome.

p.s. use console.log to debug and a browser with a developer option so you can see that output.  or just use alert() with any browser.

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
Contributor ,
Nov 10, 2017 Nov 10, 2017

Yes i was using the Javscript Console in Safari, which is where it gave me that error. I use a lot of alerts too.

I'm trying to redo a bunch of flash modules that were done years ago before the plugin is completely kaput. Just getting my fee wet with the first one, but have it mostly converted to html5 canvas. thanks again.

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 ,
Nov 10, 2017 Nov 10, 2017
LATEST

you're welcome.

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