Copy link to clipboard
Copied
i've got some movie clips on the stage on the first frame of an fla file.
The mcies have event listeners to navigate to differnet frames on the timeline. Some of the frames to which we navigate have FLVPlayback components while others dont. i'm using some code for soundchannel in this fla, to create an array and load differnt music at a btn click, so that when we go to a certain frame we get some music. This works, no overlapping music.
The issue, that when we navigate to a frame with an flv that has an audio track, the the music that's playing on a different frame just wont stop. And another issue, when we navigate from the flv frame by clicking the mc that listens for the sound channel, the flv audio track wont stop playing and we get cuckaphonia.
Prior to having the sound channel code, there was no issue with the flv audio, which would stop as soon as u navigate to another frame with not flv.
Here's how my code looks. Any help would be appreciated. And, as i'm struggling with sound code, any sound code samples would be appreciated greatly too:
nav_mc.bg1.addEventListener(MouseEvent.CLICK, buttonClicked);
nav_mc.bg0.addEventListener(MouseEvent.CLICK, buttonClicked);
nav_mc.bg2.addEventListener(MouseEvent.CLICK, buttonClicked);
function buttonClicked(event:MouseEvent):void
{
var sound:Sound = new clickmixdownmpthree;//this is a click sound that's made when we navigate to/from frames
sound.play();
}
//--------alternating bg sound -------------
var snd:Sound;
var channel:SoundChannel;
var currSong:String;
var songList:Array=new Array("1.mp3","2.mp3");
nav_mc.bg0.addEventListener(MouseEvent.CLICK, chooseSong);
nav_mc.bg1.addEventListener(MouseEvent.CLICK, chooseSong);
function chooseSong(e:MouseEvent):void {
switch (e.currentTarget.name) {
case "bg0":
currSong = ".../music/"+songList[0] as String;
break;
case "bg1":
currSong = ".../music/"+songList[1] as String;
break;
}
if (snd != null) {
channel.stop();
}
snd = new Sound();
snd.load(new URLRequest(currSong));
channel = new SoundChannel ;
channel = snd.play();
}
Hi Rob.
thanks very much for your offer but i managed to solve the issue, added some code to the block of code for navigating that i have on the first frame; added an "if" statemnt above gotoAndPlay(event.currentTarget.name);:
nav_mc.bg1.addEventListener(MouseEvent.CLICK, buttonClicked);
nav_mc.bg0.addEventListener(MouseEvent.CLICK, buttonClicked);//this was reinitiating the game
nav_mc.bg2.addEventListener(MouseEvent.CLICK, buttonClicked);
function buttonClicked(event:MouseEvent):void
{
if (
...Copy link to clipboard
Copied
There is a brute force method for killing any current sound: SoundMixer.stopAll(); A more gentle method is to tell the current video to stop playing: FLVPlayerInstance.stop(); If the video is streaming, then you can kill the stream to stop the playback: NetworkStreamName.close();
The best place to use any of those is at the point where you are leaving the frame where the video is playing, so you may want to attach the code to your navigation controls.
Copy link to clipboard
Copied
hi Rob. Am not using netstream, rather an FLVplayback component and the instanceName_flv.stop(); does NOT stop the flv and the other issues remain.
If you can address the specifics of my issues along with example code, that would be great.
Copy link to clipboard
Copied
hi again, thanks for your help, using
channel.stop();
on the FLVPlayback frame did stop the soundCHannel.
However, am still struggling to stop the FLVPlayback when on the frames that have sound channel playing.
So, am trying to attach code to the navigation away from the FLV frame, not working.
thanks very much.
Copy link to clipboard
Copied
It's difficult to prescribe a solution without a complete understanding of your movie. If you are trying to stop an FLVPlayback component when you move from the frame where it is playing to another frame that is playing a sound file, what code are you using to try and accomplish this? Does the FLVPlayback component exist in the frame where the navigation code is located?
Can I see a copy of your movie so that I can get a clearer picture of what you are trying to achieve?
Copy link to clipboard
Copied
Hi Rob.
thanks very much for your offer but i managed to solve the issue, added some code to the block of code for navigating that i have on the first frame; added an "if" statemnt above gotoAndPlay(event.currentTarget.name);:
nav_mc.bg1.addEventListener(MouseEvent.CLICK, buttonClicked);
nav_mc.bg0.addEventListener(MouseEvent.CLICK, buttonClicked);//this was reinitiating the game
nav_mc.bg2.addEventListener(MouseEvent.CLICK, buttonClicked);
function buttonClicked(event:MouseEvent):void
{
if (currentFrameLabel == "bg2")
{
nightScene_flv.stop();
}
gotoAndPlay(event.currentTarget.name);
var buttonClickedSound2:Sound = new clickmixdownmpthree;
buttonClickedSound2.play();
}
Such a simple solution that i misssed because i put the flv stop code on the frame of the that flv, and kept chasing after a fix for infamous error 1009 - missing null object method.
thanks again:)