1

I need to have a function that is accessed by Animate CC through connecting to an external file by: Global>Includes.

Then I need to run the function that is sitting on the external file when I click on a movie clip.

For example, the code on my movie clip is:

this.stop(); // stops the action on my movie clip

myFunction(); // trying to access function from external javascipt file

The code in the external file is:

function myFunction() { // this code is not being called from my movie clip

alert("working!");

}

The console log states: "myFunction" is undefined.

Thanks for the help,

Kristen

ristenk1
  • 435
  • 3
  • 6
  • 26
  • Are you trying to reproduce an example you found on the web ? –  Jan 08 '18 at 17:04
  • Maybe helpless : https://www.youtube.com/watch?v=9MB7zbjKd_M. –  Jan 08 '18 at 17:23
  • I did get it working: I'm ultimately trying to get myFunction to run a script calls a variable in Storyline Articulate... it was the user.js file from Storyline that I linked to Animate CC. – ristenk1 Jan 09 '18 at 09:10

3 Answers3

1

If you are trying to reach a global scope, which I think you are, meaning you want to place this function on one key frame and fire it from a different key frame or layer. Re write your code like this:

--- write these things this way for local ---

var foo = bar;
var count = 0;

function foobar(){
// do stuff;
}

foobar(); 
count++;


--- write these things this way for global ---

foo = bar;
count = 0;

foobar = function(){
// do stuff;
}

foobar();
count++;
  • It basically shows the differences between variables and functions being set for local and global and that the way you would call them would be the same. so, local you would declare the variable with var and write a function as function myFunction(). In the global aspect working with Adobe Animate to be able to call functions and variables from outside of a keyframe using a global scope, you would not declare the variable with var and you would write your function as myFunction = function(). – Mark Raybin Mar 06 '18 at 19:43
0

I did get it working: I'm ultimately trying to get myFunction to run a script calls a variable in Storyline Articulate... it was the user.js file from Storyline that I linked to Animate CC.

ristenk1
  • 435
  • 3
  • 6
  • 26
0

I found out the problem. The animate cc webobject was sitting in the storyline project so the webobject was a child of the parent storyline project and I couldn't get the javascript to work b/w storyline and animate cc until I added parent/child relationships when communicating between the two:

function myFunction() {

    var player = window.parent.GetPlayer();
    var test1 = player.GetVar("pie");

    alert(test1);


}
ristenk1
  • 435
  • 3
  • 6
  • 26