FORUMS: list search recent posts

actionscript 3 start and stop sound

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Michelle Aubrecht
actionscript 3 start and stop sound
on Dec 6, 2009 at 3:25:44 pm

Hello -

I'm working on an interactive game and I'm still pretty new to action script 3 and I'm not sure what to do.

Goal: The character begins talking - audio plays. When the user clicks on a question in the dialog box, I want the first audio to stop and likewise when new audio begins, other audio stops. I must be doing something wrong because I keep getting errors.

So far, all the tutorials I've found are for stopping or pausing a song in conjunction with using or creating a player. I think I need to use a sound event, but I'm not sure how to write it.

Does anyone know what to do?

Thanks, Michelle


Return to posts index

Marcus Geduld
Re: actionscript 3 start and stop sound
on Dec 6, 2009 at 6:38:49 pm


var soundChannel : SoundChannel;
var sound : Sound = new Sound();
var url : String = "http://ubu.wfmu.org/sound/365/03/365-Days-Project-03-01-welles-orson-frozen-peas-spot.mp3";

sound.addEventListener( Event.COMPLETE, soundLoaded );
sound.load( new URLRequest( url ) );

function soundLoaded( event : Event ) : void
{
soundChannel = sound.play();
stopButton.addEventListener( MouseEvent.CLICK, stopButtonClick );

function stopButtonClick( event : MouseEvent ) : void
{
soundChannel.stop();
}


Author "After Effects Expressions"
Co-author "After Effects For Flash, Flash For After Effects"
Artistic Director, Folding Chair Classical Theatre, Inc
Senior Flash Developer, Zeitbyte.com


Return to posts index

Michelle Aubrecht
Re: actionscript 3 start and stop sound
on Dec 16, 2009 at 12:27:29 pm

Hi Marcus,
This is what I was looking for (see snippet below), but I did see your book After Effects for Flash; Flash for After Effects. I ordered it and it just arrived! I'm really excited to use it. I've also watched a lot of Richard Harrington's videos about Final Cut. He does a great job. Thanks to both of you. Cheers,

Michelle

var penguin:Sound = new penguinSound();
var penguinChannel:SoundChannel;

function onyellowDown(e:MouseEvent) {
if (donkeyChannel != null) donkeyChannel.stop();
if (chimpChannel != null) chimpChannel.stop();
if (elephantChannel != null) elephantChannel.stop();
if (hippo1Channel != null) hippo1Channel.stop();
if (nightingaleChannel != null) nightingaleChannel.stop();
if (penguinChannel != null) penguinChannel.stop();
chickChannel = chick.play();
};


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]