• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

All Mouse over Action completed 1 time randomly to initiate animated screen and reset

New Here ,
Aug 03, 2020 Aug 03, 2020

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! 

Views

184

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 03, 2020 Aug 03, 2020

Copy link to clipboard

Copied

If you already have it working sequentially, what's preventing you from doing it randomly?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 03, 2020 Aug 03, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 03, 2020 Aug 03, 2020

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 03, 2020 Aug 03, 2020

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.

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 03, 2020 Aug 03, 2020

Copy link to clipboard

Copied

LATEST

HTML5 Canvas documents use JavaScript, not ActionScript.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines