1 person found this helpful
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.
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.
/* Tap Event
Tapping on the symbol instance executes a function in which you can add your own custom code.
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;
// 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.
1. Replace "http://www.helpexamples.com/flash/sound/song1.mp3" below with the desired URL address of your sound file. Keep the quotation marks ("").
//This variable keeps track of whether you want to play or stop the sound
var fl_ToPlay:Boolean = true;
var s:Sound = new Sound(new URLRequest("Hair.mp3"));
fl_SC = s.play();
fl_ToPlay = !fl_ToPlay;