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

ANCC h5 Object doesn't support property or method 'gotoAndStop'

Enthusiast ,
Aug 07, 2018 Aug 07, 2018

I want to make a key to control the movie clip's function.

But not running properly.

this.stop()
js = 0

window.addEventListener("keydown", lr, false);
function lr(e)
{
switch(e.keyCode)
{
  case 37:

   js = js -1

   name = "exportRoot.a" + js

   alert(name)

   name.gotoAndStop(2)


   break;

  case 39:
   js = js + 1
   name = "exportRoot.a" + js
   //alert(name)
   name.gotoAndStop(2)
   break;
}
}

Hint is  Object doesn't support property or method 'gotoAndStop'

410
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

LEGEND , Aug 08, 2018 Aug 08, 2018

Of course name doesn't support gotoAndStop; name is a string, not an object reference. If you want a variable reference to an object, you have to use bracket notation.

js++;

name = "a" + js;

exportRoot[name].gotoAndStop(2);

Or just...

exportRoot["a" + ++js].gotoAndStop(2);

By the way, I really hope you're declaring name somewhere as a var because otherwise you're making it a global variable. That's bad.

And you're missing semicolons at the end of all your lines of code.

Translate
LEGEND ,
Aug 08, 2018 Aug 08, 2018

Of course name doesn't support gotoAndStop; name is a string, not an object reference. If you want a variable reference to an object, you have to use bracket notation.

js++;

name = "a" + js;

exportRoot[name].gotoAndStop(2);

Or just...

exportRoot["a" + ++js].gotoAndStop(2);

By the way, I really hope you're declaring name somewhere as a var because otherwise you're making it a global variable. That's bad.

And you're missing semicolons at the end of all your lines of code.

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
Enthusiast ,
Aug 08, 2018 Aug 08, 2018

I'm sorry.

I checked the system.

I found out there was something wrong with my browser before the code went wrong.

My problem is that all the code is a hint

"Object doesn't support property or method "

Even if I only write 1 alerts ("1").

Found that there was a conflict between a software.

Uninstall the software, it's all right now.

About your help, thank you.

Calling variables across scopes, I'm not very skilled.

Writing habits and symbols, do have a problem, will pay attention to.

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
Enthusiast ,
Aug 09, 2018 Aug 09, 2018
LATEST

I've been doing this for 1 days.

The code still can't run after the software conflict problem is resolved

I finally found out the problem.

I'm so stupid.

Should have noticed that HTML5 started at 0.

Jump to frame 2nd is actually jump to frame 3rd

Modified into gotoAndStop (1);

It's going to run smoothly now.

Thank you for your help.

this.stop()

window.addEventListener("keydown", lr, false);

var js = 0;

function lr(e)

{

switch(e.keyCode)

{

  case 37:

   exportRoot["a" + js--].gotoAndStop(0);

   break;

  case 39:

   exportRoot["a" + ++js].gotoAndStop(1);

   break;

}

}

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