I am new to AS3. So what I have done is create 3 buttons on the main timeline, each button will goto a framelabel/keyframe. This all works, however in that keyframe I have a movie symbol with an FLV video embedded in it. I want to hit a button on the main timeline, goto that keyframe and the movie plays. So far this works, the problem is I want to stop the movie when I slect a different button. If I select a differnt button the movie keeps playing and if I hit that same but and go back t the movie, then the movie starts playing and I have 2 instances playing at the same time. I tried to search here, but I can't seem to find anything like what I am doing.
So here is the main timeline, I have 3 buttons on the menu layer, and separte content on each of the 3 frames at the label points.
As you can see I have a flv video embedded into a symbol (type Movie Clip), so when I select button 2 it goes and plays the movie, however when I select either button 1 or 3 to change the placement, the movie keeps playing in the background, (I can hear the audio), was hoping someone can tell me how to add code to stop this when I select a different button Below is my code I have now,
Here you can see that the video is embedded in the movieclip. I am doing this because I want to have only 1 file, I do not want an external file. I am trying to create a mobile app, so want only 1 file.
Any help help is greatly appriciated.
So I changed my code to this:
stop();
btn_page1.addEventListener(MouseEvent.CLICK, onPage1);
btn_page2.addEventListener(MouseEvent.CLICK, onPage2);
btn_page3.addEventListener(MouseEvent.CLICK, onPage3);
function onPage1(event:MouseEvent):void
{
gotoAndStop("page1");
}
function onPage2(event:MouseEvent):void
{
gotoAndStop("page2");
var dot:Dot= new Dot;
addChild(dot);
dot.x=10;
dot.y=10;
}
function onPage3(event:MouseEvent):void
{
gotoAndStop("page3");
}
where Dot is the class name of mcDot where the video is embeded. So how could I remove from stage if I press btn_page1
I tried to put removeChild(Dot) but that does not work.
any ideas
thanks
use:
stop();
var dot:Dot;
btn_page1.addEventListener(MouseEvent.CLICK, onPage1);
btn_page2.addEventListener(MouseEvent.CLICK, onPage2);
btn_page3.addEventListener(MouseEvent.CLICK, onPage3);function onPage1(event:MouseEvent):void
{removedotF();
gotoAndStop("page1");
}
function onPage2(event:MouseEvent):void
{
gotoAndStop("page2");
dot= new Dot;addChild(dot);
dot.x=10;
dot.y=10;
}function removedotF():void{
if(dot){
dot.stop();
removeChild(dot);
dot=null
}
}
function onPage3(event:MouseEvent):void
{removedotF();
gotoAndStop("page3");
}
p.s. please mark helpful/correct responses.
North America
Europe, Middle East and Africa
Asia Pacific