Skip to main content
Inspiring
May 12, 2021
Answered

Triggering a subclip

On a frame of a canvas timeline I have a movie clip with a subclip animation. It plays fine within the subclip. I am attempting to initiate that animation with a mouse click, but nothing happens. The symbol instance is "pizza" and the button instance is "pizzago." Below is my code. The script is on the same frame as the movieclip I'm trying to play. 

 

var _this = this;
_this.pizzago.on('click', function(){
_this.pizza.play();
});

This topic is closed to new replies. Start a new post to keep the conversation going.
DavidacrossAmericaCorrect answer
Inspiring
May 12, 2021

Finally got it working though it brings up an issue I need to understand better. The script was on the frame and layer where the mc lived. I moved it to my action layer, and suddenly it works. I have had another project work differently depending on placement, and I don't quite grasp why. Something to study unless someone has a suggestion for how to understand that better. Thanks all. 

4 replies

DavidacrossAmericaAuthorCorrect answer
Inspiring
May 12, 2021

Finally got it working though it brings up an issue I need to understand better. The script was on the frame and layer where the mc lived. I moved it to my action layer, and suddenly it works. I have had another project work differently depending on placement, and I don't quite grasp why. Something to study unless someone has a suggestion for how to understand that better. Thanks all. 

Translate
Legend
May 12, 2021

Add this to your event handler function:

alert(_this.pizza);

 

If it displays "undefined" when you click, things are not as you assume.

Translate
Inspiring
May 12, 2021

Didn't get that message, but that sounds like a great way to debug in the future. Thank you.

Translate
JoãoCésar17023019
Community Expert
Community Expert
May 12, 2021

Hi.

 

It should work.

 

Try...

_this.pizza.gotoAndPlay(1);

 

... instead and see if this works.

 

Regards,

JC

Translate