Skip to main content
sumanr49634048
Known Participant
December 8, 2016
Answered

How to access the function in js file which is written in Animate CC time line

  • December 8, 2016
  • 2 replies
  • 473 views

Animate CC Timeline Function

this.testFunction = function () {

console.log("welcome to CC");

}

How to access "testFunction" in js file

This topic has been closed for replies.
Correct answer ClayUUID

Man, someone is marking correct answers on autopilot today.

To access any code written inside Animate from outside Animate, use the exportRoot object. This global object is automatically defined by Animate, and points to the root timeline level. So if you defined testFunction on the root timeline, you'd access it from anywhere else on the same HTML page with:

exportRoot.testFunction();

And if the function is inside a movieclip, you'd name the movieclip and extend the reference as per usual for JavaScript:

exportRoot.myMovieClip.testFunction();

etc...

2 replies

ClayUUIDCorrect answer
Legend
December 8, 2016

Man, someone is marking correct answers on autopilot today.

To access any code written inside Animate from outside Animate, use the exportRoot object. This global object is automatically defined by Animate, and points to the root timeline level. So if you defined testFunction on the root timeline, you'd access it from anywhere else on the same HTML page with:

exportRoot.testFunction();

And if the function is inside a movieclip, you'd name the movieclip and extend the reference as per usual for JavaScript:

exportRoot.myMovieClip.testFunction();

etc...

kglad
Community Expert
Community Expert
December 8, 2016

open your js file in a text editor.