New at Flash, please help! Sound On/Off Button

I'm trying to create a button that when clicked once, it plays music, and when clicked again, it stops. I don't need the button image to change at all, I just need a simple start/stop.
I've been able to make the button start the music when clicked but I've not been successful in making it stop.
I am using CS4, and have no scripting experience.
This is for a graphic arts assignment so please help!

drag your button to the stage and assign it an instance name (eg, btn).  you can then use:
var sound:MP3=new MP3();
var sc:SoundChannel = sound.play();
btn.addEventListener(MouseEvent.CLICK,f);
function f(e:MouseEvent):void{
if(sc){
sc.stop();
sc=null;
} else {
sc=sound.play();

Similar Messages

Maybe you are looking for

  • Cannot connect HP1102w to Mac with OS 10.8.5

    "Cannot install the software for the HP 1102w because it is not currently available from the Software Update server". I downloaded software per the link on another similar post  http://support.apple.com/kb/DL907 I dragged the package icon to Applicat

  • BAPI or RFC for DP90

    Hi experts, I would like to know if there is any standard BAPI or RFC to Execute DP90 transaction in CS. This is in order to do the complete service order creation cycle through a small application in Enterprise Portal. Can any one please help me out

  • Read cluster PCL4 .. takes lot of time

    Hi guys,   Though I Know this is a functional related forum, i would want to post  techincal question related HR ABAP. I have a report that needs to read data from PCL4 cluster and display master data changes for an employee. Developed a big program

  • Block throws exception ?

    is it possible to suggest that a block will throw an exception ... i.e.:static throws Exception { } is invalid ... i suppose its not possible ... ?

  • When trying to import videos, pop up says not the right kind of document

    I am on photoshop elements 13 editor, trying to import videos. A pop up says could not complete your request because it is not the right kind of document. Any solutions?