Hi all ...
I'm having difficulty with my Adobe Edge Animate code finesse, and I could use some advice. I'm more of a coder than an Edge/Flash guy, so I'm having trouble understanding the scope of variables and where I can use variables and anonymous functions on the global scope.
I wrote a Tic-Tac-Toe game in Edge Animate, and I'd like many of my functions to be scoped globally so that I can just call them on a click action and play back the timeline once the function returns a response.
Here's a typical onclick action:
thisSym = sym.getSymbol("b1");
var thisWinner = checkChoice(1, thisSym);
// problematic code
if (thisWinner === 1) {
sym.getSymbol("winBox").$("theText").html("X WINS!");
sym.play(2500);
} else if (thisWinner === 2) {
sym.getSymbol("winBox").$("theText").html("O WINS!");
sym.play(2500);
}
Note that b1 is a square on the Tic-Tac-Toe grid and checkChoice is a function I wrote in Full Code view to handle checking whether the clicked box returns a winner.
Currently, when I return a winner (1 for "X", 2 for "O") you'll note that I can go to a specific area on the timeline, dynamically update the text to say "X Wins" or "O Wins" depending on whomever wins, and then sym.play(2500) to go to the main timeline.
Here's the problem: I want to abstract the portion of this click action that comes after my comment //problematic code. What's stopping me? The ability to control the stage timeline from outside of the stage scope in the code. I can *do* all the logic and get console.log to print whatever I want, but I can't get the stage to move to 2500.
Any thoughts or advice? A good article on using custom functions in Edge Animate would be extremely helpful.
Thanks!
William