Skip to main content
Participating Frequently
April 5, 2010
Question

stopping sound without a button

  • April 5, 2010
  • 1 reply
  • 1384 views

Is it possible to stop a sound playing without a button?  I have background music on frame 1 but before I move onto frame 2 I want the sound to stop. I have 5 buttons on frame 1 to lead to different frames but I do not want them to control the sound. I also do not want to use stop all sounds on the next frame as I want sounds to work on those pages. The script below is to start the sound so how do I stop it from continuing onto the next frames when the control buttons are clicked.

import flash.media.SoundChannel; 
var sc:SoundChannel=new SoundChannel(); 
sc=new walk().play();

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 5, 2010

sc.stop();

3storeysAuthor
Participating Frequently
April 5, 2010

Whether I place that script I get the following message and if I place it on the actual frame the sound is on it stops the sound before it has begun

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at digitalnarrative_fla::MainTimeline/frame2()

kglad
Community Expert
Community Expert
April 5, 2010

that error's not related to the code i suggested unless you're trying to use sc before it's assigned.

click file/publish settings/flash and tick "permit debugging".  retest.  the line number in frame 2 that contains that error will be mentioned in the error message.