Raymond
Raymond

Reputation: 91

How to stop a video in a scene from playing after i move to another scene in flash?

I have 2 scenes, both with buttons linking both scenes together. But I encounter a problem when moving from scene 1 to scene 2. The video playing in scene 1 continue to play after i have when on to scene 2 to view another video. Is there a way to stop the previous video?

Here are my code in Adobe Flash CC action script.

Button 1 in scene 1

button_1.addEventListener(MouseEvent.CLICK, Scene_1ToScene2);

function Scene_1ToScene2(event: MouseEvent): void {
	gotoAndPlay(1, "Scene 2");
	stop();
}

Button 2 in scene 2

button_2.addEventListener(MouseEvent.CLICK, Scene_2ToScene1);

function Scene_2ToScene1(event: MouseEvent): void {
	gotoAndPlay(1, "Scene 1");
	stop();
}

Upvotes: 0

Views: 3391

Answers (3)

Marcia Ong
Marcia Ong

Reputation: 781

You need to give your video a name Eg.enter image description here

After that go the actionscript side and use this code

button_1.addEventListener(MouseEvent.CLICK, Scene_1ToScene2);

function Scene_1ToScene2(event: MouseEvent): void {
flv.Stop(); 
gotoAndPlay(1, "Scene 2");

}  

Upvotes: 0

Raymond
Raymond

Reputation: 91

Add in

Video_001.stop();

"Video_001" is the instance name of the video.

Upvotes: 1

Timothy Kovalev
Timothy Kovalev

Reputation: 325

Call stop() before calling gotoAndPlay(). That must help.

Upvotes: 0

Related Questions