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

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

Explorer ,
Apr 08, 2019 Apr 08, 2019

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!

713
Translate
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 ,
Apr 08, 2019 Apr 08, 2019

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

Translate
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
Explorer ,
Apr 08, 2019 Apr 08, 2019

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.

Translate
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 ,
Apr 08, 2019 Apr 08, 2019

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

Translate
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
Explorer ,
Apr 09, 2019 Apr 09, 2019

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...

Translate
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
Enthusiast ,
Apr 09, 2019 Apr 09, 2019

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.

Translate
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
Explorer ,
Apr 10, 2019 Apr 10, 2019

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.

Translate
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 ,
Apr 10, 2019 Apr 10, 2019
LATEST

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

Translate
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