0
votes

Hi I'm new with adobe flash player CS6 action script. My problem is when I click another page / frame the video player keep playing. I use XML to load the video.

This is my code snippets

 stop();

import flash.net.URLLoader;
import flash.events.Event;

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE,xmlloaded);

var xml:XML = new XML();
var amountofvid:Number=0;
var currentvideo:Number=0;

btn1.addEventListener(MouseEvent.CLICK,prevvid);
btn2.addEventListener(MouseEvent.CLICK,nextvid);

function xmlloaded(e:Event){
    xml=XML(e.target.data);
    amountofvid=xml.video.length()-1;
    changevid();
    }

function nextvid(e:Event){
    currentvideo++;
    changevid();
    }

    function prevvid(e:Event){
        currentvideo--;
        changevid();
        }

function changevid():void{
    var cv:Number=Math.abs(currentvideo);


    if(cv>amountofvid){

        currentvideo=cv=0;
        }

        if(currentvideo<0){

            currentvideo=cv=amountofvid;
            }
    vid.source=xml.video.@src[cv];
    }

loader.load(new URLRequest('video.xml'));

Please any helps, thank you

2
XML loading routine is totally irrelevant. You shouldn't have mentioned it at all. The only useful line in your script is vid.source = ... You should go to official Adobe documentation (help.adobe.com/en_US/FlashPlatform/reference/actionscript/3), find the video playback class you are using as vid and figure a method to call to stop it. As far as Adobe developers are usually sane, the method will be called stop or maybe pause.Organis
Hi thank you, just got the solution. I put this flash.media.SoundMixer.stopAll(); And stop the video from playinggogocoder
It's a peg leg of a solution. This command stops all the currently playing sound channels, but is does not really stops the video, which is detached from display list yet keeps playing somewhere where you cannot see it.Organis

2 Answers

2
votes

Sorry putting flash.media.SoundMixer.stopAll(); that was very bad solution, because it will kills all sound, my solution is by putting event

vid.addEventListener(Event.REMOVED_FROM_STAGE, stopPlay);
function stopPlay(e:Event)
{
      vid.stop();
}

This works correct as this link explanation

https://forums.adobe.com/thread/773601

Thank you

-1
votes

Solution I put this code in the beginning of frame

flash.media.SoundMixer.stopAll();