A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Stop a sound

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Posts
    18

    Exclamation Stop a sound

    I have a "play screen" and there is music on the play screen that starts automatically. However, when you click "play" I want the music to stop.

    However, I can to "stopallsounds" because there are other sounds in the animation. Can anyone help?

    Thanks,
    D

  2. #2
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    how are you loading the sound?
    if your using a sound object, try
    PHP Code:
    sound.stop()//where "sound" is the variable for the sound object 
    If you don't think you're going to like the answer, then don't ask the question.

  3. #3
    Junior Member
    Join Date
    Dec 2007
    Posts
    18
    Well, to tell the truth, I am not sure how to go about attaching sounds. I simple put the sound in its own layer above the section of animation it partains to. o.O

    D

  4. #4
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    to use attachSound, do the following;
    in the library is where sound is, right? go to the library and right-click on the sound and select linkage. when the dialog box comes up, click on the first check box that says "Export for Actionscript" and then click "OK"
    now the sound can be attached to an object, which is the next step.
    go to the frame where you want to put the sound, say frame 1 for example. type the following

    PHP Code:
    mysound = new Sound()
    mysound.attachSound("linkage_name_you_gave_it")//it will be the same name as the name in the library unless you changed it when you created the linkage.
    mysound.start(0,0)//0,0 means - the first zero is the position the sound will start at (the beginning), and second zero is the loop(how many times to repeat the sound 
    to stop the sound from a button you can put on the button itself this script
    PHP Code:
    on(release){
       
    mysound.stop()

    there is a excellent tutorial by Kenny Bellew that covers it all
    Last edited by EQFlash; 04-30-2008 at 10:54 PM.
    If you don't think you're going to like the answer, then don't ask the question.

  5. #5
    Junior Member
    Join Date
    Dec 2007
    Posts
    18
    Yes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center