2 Replies Latest reply on Dec 25, 2015 8:09 AM by georgem59111643

    Help me disable extraneous screen touches that are not on buttons

    georgem59111643

      I am totally new to making mobile apps for touch screen tablets.

      I am trying to copy the premise of a "drum" app where you click on a drum image and it makes a drum sound. BUT, even if you place another finger elsewhere on the screen, the drums still work.

      My app also has buttons that play a .wav sound when you press them, BUT if you place one finger elsewhere on the screen, ALL the buttons stop working.

       

      I'll try to explain how I made this app in case it helps discover my mistake.

      Selected Air for Desktop

      Changed dimensions to 768x1080 pixel

      Imported one .jpg image and nine .wav files

      Dragged image into first and only frame

      Created new layer and called it "Buttons"

      Used square drawing tool and solid color to draw shape over background image

      Right clicked on shape and converted it to symbol>button

      Right clicked on the new Button in Library and > Edit

      Selected Hit frame and Insert Keyframe

      Selected Hit frame > Properties and assigned a .wav file to the button

      Switch back to home screen Ctrl-Enter to test and it works fine

      Then Publish Settings > Windows Installer and that works fine too

       

      Thanks in advance

        • 1. Re: Help me disable extraneous screen touches that are not on buttons
          Colin Holgate MVP & Adobe Community Professional

          You're using mouse events, you need to learn about touch events. If you look at the Code Snippets window you can see some example touch events scripts.

          1 person found this helpful
          • 2. Re: Help me disable extraneous screen touches that are not on buttons
            georgem59111643 Level 1

            Thanks! I thought I was heading in the right direction, but ...

            I drew a rectangle, converted it to a symbol, selected the symbol, opened code snippets, double clicked Mobile > Tap Event and also Sound > PlayStop Sound

            But now I notice that the first code says TouchEvent while the PlayStop Sound says MouseEvent...which I'm not supposed to be using...

             

            I can click the defined area to play a sound, but when I click it a second time it executes a "stop."

            I would like it to play the sound once every time it's clicked and stop automatically.

            Please tell me how to edit this code snippet to achieve that.

            Thanks

             

             

             

            /* Tap Event

            Tapping on the symbol instance executes a function in which you can add your own custom code.

             

             

            Instructions:

            1. Add your custom code on a new line after the line that says "// Start your custom code" below.

            The code will execute when the symbol instance is tapped.

            */

             

             

            Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

             

             

            movieClip_1.addEventListener(TouchEvent.TOUCH_TAP, fl_TapHandler);

             

             

            function fl_TapHandler(event:TouchEvent):void

            {

              // Start your custom code

              // This example code reduces the transparency of the object by half upon each tap event

              movieClip_1.alpha *= 0.5;

              // End your custom code

            }

             

             

            /* Click to Play/Stop Sound

            Clicking on the symbol instance plays the specified sound.

            Clicking on the symbol instance a second time stops the sound.

             

             

            Instructions:

            1. Replace "http://www.helpexamples.com/flash/sound/song1.mp3" below with the desired URL address of your sound file. Keep the quotation marks ("").

            */

             

             

            movieClip_1.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound);

             

             

            var fl_SC:SoundChannel;

             

             

            //This variable keeps track of whether you want to play or stop the sound

            var fl_ToPlay:Boolean = true;

             

             

            function fl_ClickToPlayStopSound(evt:MouseEvent):void

            {

              if(fl_ToPlay)

              {

              var s:Sound = new Sound(new URLRequest("Hair.mp3"));

              fl_SC = s.play();

              }

              else

              {

              fl_SC.stop();

              }

              fl_ToPlay = !fl_ToPlay;

            }