Copy link to clipboard
Copied
Hello - I'm trying to simulate a game-like interaction using adobe animate action scripts.
Essentially I'm building a screen where there are 5 shapes (buttons) on the screen, once they are all clicked - in any order the user desires - the screen would go to a keyframe that plays an end-scene animation then reset.
I'm only able to get this to work sequentially but need this to work randomly - where the buttons are pressed in no specific order. Does Animate CC support something like this? If this requires a custom script any suggestions for places to look would be appreciated!
Copy link to clipboard
Copied
If you already have it working sequentially, what's preventing you from doing it randomly?
Copy link to clipboard
Copied
lack of experience with Animate? 🙂 It seems doable but I'm stuck at how to set up an animation that plays when each button has been moused over once.
Copy link to clipboard
Copied
Hi.
There are several ways to do this kind of interaction. One way is to place all buttons in the same container and then store the ones that have been clicked in an array without allowing duplicates. Then check if the array length is equal to the total of instances in the container.
Assuming that you're working on an HTML5 Canvas document, the code could be something like this:
var root = this;
root.checkButtons = function(e)
{
if (root.buttons.indexOf(e.target) === -1)
root.buttons.push(e.target);
if (root.buttons.length === root.container.numChildren)
root.gotoAndStop(1);
};
root.container = this;
root.buttons = [];
root.stop();
root.container.on("click", root.checkButtons);
Please let us know.
Regards,
JC
Copy link to clipboard
Copied
Thanks JC - I'm a bit new to Animate and ActionScripts. Your information seems thorough but I don't know what containers/arrays are or know enough to test the code yet. https://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7ee3.html
This seems in line with what you mentioned (?), I'll probably need to look into more documentations. And I am working in a HTML5 Canvas document.
Copy link to clipboard
Copied
HTML5 Canvas documents use JavaScript, not ActionScript.