Skip to main content
EricLabonte
Participating Frequently
May 11, 2023 6:29 PM UTC
Question

Cannot create an addEventListener to movieclip in frame 3 (HTML5 Canvas)

On the main timeline, I have different interfaces to a game I am creating. They are all placed on different keyframes.

On frame 3 (which is a keyframe) of main timeline, I have 9 different buttons. On this frame, I have code to create EventListeners for these buttons, but I receive the error of "undefined".

I believe that the code is being executed before the buttons are actually created on the canvas.

Is there an "on loaded" or "on complete" event that I can assign to the frame, so that I can execute code once every object in the frame is created on the canvas?

Thanks for your help.

This topic is closed to new replies. Start a new post to keep the conversation going.

8 replies

JoãoCésar17023019
Community Expert
Community Expert
May 11, 2023 6:36 PM UTC

Hi.


[EDITED: now that I saw in the title that it is the HTML5 Canvas document.]

 

Are the buttons components?

Please let us know.

Regards,
JC

Translate
EricLabonte
Participating Frequently
May 11, 2023 6:40 PM UTC

I am using HTML5 Canvas document, and the buttons are not components. They are objects of the type "Button". To help clarify, I draw a circle and use the "create symbole" of the type "Button".

 

Translate
JoãoCésar17023019
Community Expert
Community Expert
May 11, 2023 6:43 PM UTC

Got it.

 

Can you show us a screenshot of your code and a screenshot of the frame that has the buttons?

Translate