Hi there !
I try to find good practices for my game development. I'm learning AS3 and it's very hard to find two tutorials or books which explain exactly the same methodology for the same thing.
Here's my "problem" : I try to shut all the sound channels of all the movieclips called and used in my main Class ("Controller").
I found the great tip : SoundMixer.stopAll(); and it works !
... But using channels in children movieclips, everytime i add them (new occurence via addchild) to the controller after having the sounds stopped, the sounds in these children are still playing.
Some example code to explain it better... ^^
Controller class
"Turn the sound off" function in the controller classPHP Code:package
{ import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.events.*;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
public class Controller extends MovieClip
{
public var soundControllerChannel:SoundChannel;
private var controlSoundButton:ControlSoundButton;
PHP Code:function ClickControlSoundButton(event:MouseEvent):void
{
SoundMixer.stopAll();
}
Missile explosion class
So when i click the button to turn the sound off on the controller, every explosion already added on it are muted. The ones which are added after this are not muted.PHP Code:package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.media.Sound;
import flash.media.SoundChannel;
public class MissileExplosion extends MovieClip
{
private var explosion_mc:MovieClip = new MovieClip();
private var timer:Timer = new Timer(300);
public var smallExplosion:SmallExplosion;
private var soundExplosion:SoundExplosion;
private var soundExplosionChannel:SoundChannel;
public function MissileExplosion(MissileExplosionX,MissileExplosionY)
{
//SONS
soundExplosion = new SoundExplosion;
soundExplosionChannel = new SoundChannel;
soundExplosionChannel = soundExplosion.play();
this.x = MissileExplosionX;
this.y = MissileExplosionY;
etc... etc...
What's the best methodology to avoid this problem ?
I hope it's clear because my english is far from fluent ! Sorry for that ^^
Thank you !




Reply With Quote