Copy link to clipboard
Copied
Hello !
First, I apologize for my english, I'm a french graphic student trying to develop an animation in Flash, using AS3.
My problem is : I'm using a sound, and I want it to stop when you click on my object (Montagne), and then restart it if you click again.
Here's my code :
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.events.MouseEvent;
import flash.net.URLRequest;
var music:Sound = new Sound(new URLRequest("fond.wav"));
var sc:SoundChannel = Sound.play();
sc.play();
Montagne.addEventListener(MouseEvent.CLICK, stopMusic);
function stopMusic(event:MouseEvent){
if(Montagne.currentFrameLabel =="Etape_2"){
trace("youpi");
sc.stop();
}else{
(Montagne.currentFrameLabel =="Etape_3"){
trace("itizok");
sc.play();
}
}
}
I have two syntax errors that I can't correct :
1086 : expecting semicolon before left brace
1084 : expecting right brace before left brace
I googled it many times, but I'm definitively blocked...
A little help could be so great ! Thank you in advance !
Copy link to clipboard
Copied
try:
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.events.MouseEvent;
import flash.net.URLRequest;
var music:Sound = new Sound(new URLRequest("fond.wav"));
var sc:SoundChannel = Sound.play();
Montagne.addEventListener(MouseEvent.CLICK, stopMusic);
function stopMusic(event:MouseEvent){
if(Montagne.currentFrameLabel =="Etape_2"){
trace("youpi");
sc.stop();
}else{
if (Montagne.currentFrameLabel =="Etape_3"){
trace("itizok");
sc = music.play();
}
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now