Highlighted

Enable several buttons to be pressed at once in Adobe air-app?

Explorer ,
Apr 08, 2019

Copy link to clipboard

Copied

I'm working on a piano-project and would like the player to be able to press several keys (buttons) at the same time. Problem is I can only make one button work at a time (when you try to press more than one, nothing happens). Tried to google the problem but can't find it for my life. Is there a fix to this? Would be amazing!

Views

430

Likes

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

Enable several buttons to be pressed at once in Adobe air-app?

Explorer ,
Apr 08, 2019

Copy link to clipboard

Copied

I'm working on a piano-project and would like the player to be able to press several keys (buttons) at the same time. Problem is I can only make one button work at a time (when you try to press more than one, nothing happens). Tried to google the problem but can't find it for my life. Is there a fix to this? Would be amazing!

Views

431

Likes

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
Apr 08, 2019 0
Adobe Community Professional ,
Apr 08, 2019

Copy link to clipboard

Copied

Hi.

You need to change the input mode to allow multitouch/gestures.

Multitouch.inputMode = MultitouchInputMode.GESTURE;

Then, when testing inside of Animate CC, you have to go to the Simulator > TOUCH AND GESTURE > Touch layer and choose the appropriate kind of gesture you want.

Or just test in an actual device.

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Apr 08, 2019 2
Explorer ,
Apr 08, 2019

Copy link to clipboard

Copied

Thank you for a really fast reply! I It didn't work though when I tried the app on my smart pad. I'm a noob when it comes to coding. Do I have to define the gesture (tap in this case)? So far I just used the button functions without any coding involved.

Likes

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
Reply
Loading...
Apr 08, 2019 0
Adobe Community Professional ,
Apr 08, 2019

Copy link to clipboard

Copied

Here is an example that hopefully will clarify things for you.

I tested this code on an Android Phone and it worked. There may be some touch devices that don't have a good compatibility or no compabitibility with multi touch and/or AIR at all.

AS3 code:

import flash.ui.Multitouch;

import flash.events.TouchEvent;

import flash.ui.MultitouchInputMode;

import flash.display.MovieClip;

var targets:Vector.<MovieClip> = new Vector.<MovieClip>();

function start():void

{

    Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

    keys.addEventListener(TouchEvent.TOUCH_BEGIN, touchBeginHandler);

    stage.addEventListener(TouchEvent.TOUCH_END, touchEndHandler);

}

function touchBeginHandler(e:TouchEvent)

{

    targets.unshift(e.target as MovieClip);

    targets[0].gotoAndStop(2);

}

function touchEndHandler(e:TouchEvent)

{

    for (var i:int = targets.length - 1; i >= 0; i--)

          targets.gotoAndStop(1);

    targets.splice(0, targets.length);

}

start();

FLA download:

animate_cc_as3_multitouch.zip - Google Drive

Please don't hesitate to ask if you still have any further questions.

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Apr 08, 2019 1
Enthusiast ,
Apr 09, 2019

Copy link to clipboard

Copied

Which button functions are you referring to, that doesn't involve any coding?

Multi touch + Adobe AIR works great on all Android/iOS devices, but you would need to do a little coding, as JC pointed out.

Likes

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
Reply
Loading...
Apr 09, 2019 1
Explorer ,
Apr 09, 2019

Copy link to clipboard

Copied

Ok, now it says Connection failure when I try to publish it. I haven't installed the app on the Android through Animate before. Just dragged the file and then installed it directly on the Android tablet. On an older Flash version it says "Access of undefined property keys" under Compiler errors when I try to publish it. 

I see the code involves "import". Does that mean I have to use plug-ins? Again - sorry, I'm really not good with coding...

Likes

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
Reply
Loading...
Apr 09, 2019 0
Explorer ,
Apr 10, 2019

Copy link to clipboard

Copied

Thank you for the reply. It's when I make several symbols (buttons) like in this video (How to Create a Piano in Adobe Animate CC - YouTube) that I can't make them be pressed several at once, but rather one at a time.

Likes

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
Reply
Loading...
Apr 10, 2019 0
Adobe Community Professional ,
Apr 10, 2019

Copy link to clipboard

Copied

Hi again.

I think the problem you have now is not related to AS3. Rather you need assistance on how to publish AIR for Android apps, I guess.

Please have a look at this guide:

Publishing AIR for Android applications in Animate CC

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Apr 10, 2019 1