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

dispatchEvent

Community Beginner ,
Dec 24, 2017 Dec 24, 2017

Copy link to clipboard

Copied

Hi, I don't undertstand why this is working

main script firts frame :

this.on("gameover", function() {

     this.gotoAndStop('gameover');

});

with this in a clip :

this.dispatchEvent("gameover", true);

but this function in the main script is not working:

function eval(){

   if(clics==maxClics){

    this.dispatchEvent("gameover", true);

   }

}

thanks and merry christmas

Views

300

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

Community Expert , Dec 25, 2017 Dec 25, 2017

so you can rule out the last option if that's all on the same timeline.  these three possible issues remain:

clics may not be defined (in that function)

maxClics may not be defined (in that function)

this may not be defined in that function

use console.log to debug.

Votes

Translate

Translate
Community Expert ,
Dec 24, 2017 Dec 24, 2017

Copy link to clipboard

Copied

clics may not be defined (in that function)

maxClics may not be defined (in that function)

this may not be defined in that function

and you may not be dispatching from the correct timeline

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
Community Beginner ,
Dec 25, 2017 Dec 25, 2017

Copy link to clipboard

Copied

Hi, first i changed the function name as  ClayUUID suggested it. with no better success.

For kglad remarq : this is the whole code, all in the first frame, first level:

this.on("gameover", function() {

     this.gotoAndStop('gameover');

});

function  evalscore(){
   if(clics==maxClics){
    this.dispatchEvent("gameover", true);
   }
}

function obj_bon(obj) {

    score++;

    clics++;
    evalscore();
}

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
Community Expert ,
Dec 25, 2017 Dec 25, 2017

Copy link to clipboard

Copied

LATEST

so you can rule out the last option if that's all on the same timeline.  these three possible issues remain:

clics may not be defined (in that function)

maxClics may not be defined (in that function)

this may not be defined in that function

use console.log to debug.

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 ,
Dec 25, 2017 Dec 25, 2017

Copy link to clipboard

Copied

There's already a global "eval" function in JavaScript. You can't override it.

eval() - JavaScript | MDN

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