Skip to main content
February 16, 2013
Answered

hi

  • February 16, 2013
  • 1 reply
  • 786 views

hello

i  have a code to play and stop music with the URLRequest

the code is not on the main time line and when i run  it , woks ok

BUT i want it to play only on one frame

when i move to the next frame,( i move to the next frame on my main class)

it's keep playing the music

how can i stop the music when i move to the nextframe?

Thnak you for your help

This topic has been closed for replies.
Correct answer Ned Murphy

The Sound class does not have a stop() method.  What you need to do is assign the play() method of your Sound object to a SoundChannel object and then use the SoundChannel object to stop() the sound.

Something like...

var sc:SoundChannel;

var a:Sound = new meme();

sc = a.play();

and when you want to stop the sound you stop the SoundChannel...

sc.stop();

1 reply

Ned Murphy
Brainiac
February 16, 2013

Use the code that stops the music before you change the frame.

February 16, 2013

HI

i wrote this code to stop the music but give me an error

var a:Sound = new meme();

            a.stop();

Line 631061: Call to a possibly undefined method stop through a reference with static type flash.media:Sound.

i put the code at the main class also import import flash.media.Sound;

how can i fix the problem?

thank you

Ned Murphy
Ned MurphyCorrect answer
Brainiac
February 16, 2013

The Sound class does not have a stop() method.  What you need to do is assign the play() method of your Sound object to a SoundChannel object and then use the SoundChannel object to stop() the sound.

Something like...

var sc:SoundChannel;

var a:Sound = new meme();

sc = a.play();

and when you want to stop the sound you stop the SoundChannel...

sc.stop();