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

Need help understanding an HTML5 error

Explorer ,
Jun 21, 2017 Jun 21, 2017

So I'm putting together a website with Animate CC and I'm using an HTML5 canvas....which I'm reasonably new at.  I'm putting together a gallery section with multiple categories, which are all contained inside a master "Gallery" movieclip.  The gallery sections each have thumbnail images, which are clicked on to reveal a larger version of the image and then when the large version is clicked on it disappears. 

The first section worked perfectly.  Here's how I did it.  I used this code to make the larger image invisible to start:

this.DinoZombies.visible = false;

Then attached this code to the corresponding thumbnail to reveal it:

this.DinoZombiesBTN.addEventListener("click", fl_MouseClickHandler.bind(this));

function fl_MouseClickHandler()

{

  this.DinoZombies.visible = true;

}

Then attached this code to the fullsized image so it could be turned back off:

this.DinoZombies.addEventListener("click", fl_ClickToHide_3.bind(this));

function fl_ClickToHide_3()

{

  this.DinoZombies.visible = false;

}

Everything worked fine but when I moved onto the next section of the gallery and used the exact same approach for the new images, it wouldn't export properly and I got these errors:

Failed to load resource: the server responded with a status of 404 (Not Found)

New-Websitev4.js?1498061590809:10881 Uncaught TypeError: Cannot set property 'visible' of undefined

    at lib.GallerySection.frame_0 (New-Websitev4.js?1498061590809:10881)

    at a.b._runActions (createjs-2015.11.26.min.js:17)

    at a.b.setPosition (createjs-2015.11.26.min.js:17)

    at a.b.setPosition (createjs-2015.11.26.min.js:17)

    at lib.GallerySection.c._updateTimeline (createjs-2015.11.26.min.js:14)

    at lib.GallerySection.c.advance (createjs-2015.11.26.min.js:14)

    at lib.GallerySection.c._tick (createjs-2015.11.26.min.js:14)

    at lib.NewWebsitev7.b._tick (createjs-2015.11.26.min.js:13)

    at lib.NewWebsitev7.c._tick (createjs-2015.11.26.min.js:14)

    at a.b._tick (createjs-2015.11.26.min.js:13)

New-Websitev4.js?1498061590809:13135 Uncaught TypeError: Cannot read property 'addEventListener' of undefined

    at lib.NewWebsitev7.frame_99 (New-Websitev4.js?1498061590809:13135)

    at a.b._runActions (createjs-2015.11.26.min.js:17)

    at a.b.setPosition (createjs-2015.11.26.min.js:17)

    at a.b.setPosition (createjs-2015.11.26.min.js:17)

    at lib.NewWebsitev7.c._updateTimeline (createjs-2015.11.26.min.js:14)

    at lib.NewWebsitev7.c.advance (createjs-2015.11.26.min.js:14)

    at lib.NewWebsitev7.c._tick (createjs-2015.11.26.min.js:14)

    at a.b._tick (createjs-2015.11.26.min.js:13)

    at a.b.tick (createjs-2015.11.26.min.js:13)

    at a.b.update (createjs-2015.11.26.min.js:13)

My primary field is animation so coding and deciphering errors like this isn't really my strong suit anyway but it doesn't make sense to me that it's having issues with this code that I've already succesfully used before.  It actually sites "event listeners" and "visible" as being issues but they've been used without issue already in the website.

Please help!

Thanks

2.8K
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 , Jun 21, 2017 Jun 21, 2017

"Cannot set property 'visible' of undefined"

You can't set a property on something that doesn't exist yet, or ever.

Try sticking a console.log(this); before where you're getting the error.

Translate
Community Expert ,
Jun 21, 2017 Jun 21, 2017

you failed to use the correct reference to one or more objects.

the easiest way to find that object is to object your published html in a browser and use the developers console to see the line of code in New-Websitev4.js that's triggering the problem.

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
Explorer ,
Jun 21, 2017 Jun 21, 2017

The console's actually how I found those errors that I pasted.  But I can't tell to look at them what the problem line of code is.  If it's explained there, I'm not understanding it.

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 ,
Jun 21, 2017 Jun 21, 2017

check your network tab then to see if that tells you what's 'not found'.

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
Explorer ,
Jun 21, 2017 Jun 21, 2017

Okay....I THINK I'm starting to see some issues.  Still not entirely clear on what's wrong with some of the code...but this is helping me narrow it down so I can figure it out.

I've noticed another issue though that I hadn't noticed before.

So I have buttons that take me to different points on the timeline.  And at those points are movieclips with stuff and code inside.  But I also have a back button appearing at these points on the main timeline, to move back to the front page of the site.  The back button works fine on sections where I haven't added the movieclip content yet...but doesn't work on the sections with added content.  It's almost as if the code inside the movieclip is canceling out the code on the main timeline.

Any thoughts as to why this could be?

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
LEGEND ,
Jun 21, 2017 Jun 21, 2017

"Cannot set property 'visible' of undefined"

You can't set a property on something that doesn't exist yet, or ever.

Try sticking a console.log(this); before where you're getting the error.

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
Explorer ,
Jun 21, 2017 Jun 21, 2017

No I get what the "undefined" thing means...it's just sometimes I can't immediately tell why it's not being defined right away...and I'm encountering other issues.

I also got the undefined error referring to a line of code in the preloader....but I'm using the default preloader that it comes with...I didn't make it myself, so I don't see how I can fix that.

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 ,
Jun 21, 2017 Jun 21, 2017
LATEST

for problems that do not trigger an error message use console.log() to pinpoint the issue similar to clay's suggestion.

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