Skip to main content
Inspiring
June 21, 2017
Answered

call function from main canvas inside a symbol

  • June 21, 2017
  • 2 replies
  • 1353 views

Hi,

I'm a newbie with Animate CC and JavaScript, so bear with me if I use the wrong terms - I'll try to be as clear as possible.

Let's say we have the following function written on frame 1 of the main canvas:

this.exampleFunction = function (message) {

    console.log(message);

}

So I'm happy because I can call this function even when I'm on frame 100. But let's say I create a Symbol Definition - I double click something on my canvas, and I'm brought to this "new layer" where I can edit stuff. From here, I start adding code as well. Everything works, but I can't seem to call the function (exampleFunction) I made on frame 1.

How would I go on about doing this? Let me know if we need more info to tackle this problem!

This topic has been closed for replies.
Correct answer UDESCO

You can call it in two ways :-

this.parent.exampleFunction('message');

exportRoot.exampleFunction('message'); //exportRoot refers to the main timeline.

2 replies

Legend
June 22, 2017

byunghoona16325993  wrote

I'm a newbie with Animate CC and JavaScript, so bear with me if I use the wrong terms

There is no "main" canvas. There is only one canvas. You mean the main (or "root") timeline.

Going inside a symbol does not access a "new layer", it accesses a new timeline.

UDESCO
UDESCOCorrect answer
Participating Frequently
June 22, 2017

You can call it in two ways :-

this.parent.exampleFunction('message');

exportRoot.exampleFunction('message'); //exportRoot refers to the main timeline.