Skip to main content
Participant
December 26, 2016
Answered

FlvPlayback Problem

  • December 26, 2016
  • 1 reply
  • 344 views

My question seems very simple but i could not manage it.

I put a FLVplayback in my flash. I have three buttons. When the user hits the button i want the videos play in a line.

In first button 01A.flv then 01B.flv then 01C.flv

In second button 02A.flv then 02B.flv

Tn third button 03.flv only.

I could not manage it.

Here is my AS3

Thanks for the help.

stop();

zero.addEventListener(MouseEvent.CLICK,zero1)

function zero1(e:MouseEvent):void{

gotoAndStop(1)

}

one.addEventListener(MouseEvent.CLICK, vid1);

two.addEventListener(MouseEvent.CLICK, vid2);

two.addEventListener(MouseEvent.CLICK, vid2B);

three.addEventListener(MouseEvent.CLICK, vid3);

function vid1(event:MouseEvent):void

{

vidPlayer.source = "01A.flv"

}

one.addEventListener(MouseEvent.CLICK,d1)

function d1(e:MouseEvent):void{

gotoAndStop(2)

}

function vid2(event:MouseEvent):void

{

vidPlayer.source = "02A.flv";

}

function vid2B(event:MouseEvent):void

{

vidPlayer.source = "02B.flv";

}

two.addEventListener(MouseEvent.CLICK,d2)

function d2(e:MouseEvent):void{

gotoAndStop(2)

}

function vid3(event:MouseEvent):void

{

vidPlayer.source = "03.flv";

}

three.addEventListener(MouseEvent.CLICK,d3)

function d3(e:MouseEvent):void{

gotoAndStop(2)

}

// for clarification

var video:FLVPlayback = vidPlayer;

video.autoPlay = true;

video.addEventListener(Event.COMPLETE, function(e:Event) {

    // video has finished

  gotoAndPlay(1);

});

Message was edited by: adil congur

    This topic has been closed for replies.
    Correct answer kglad

    stop();

    var videoA:Array=[ ['01A.flv','01B.flv','01C.flv'], ['02A.flv,'02B.flv'] ];

    var vidIndex:int;

    var subIndex:int;

    video.autoPlay = true;

    video.addEventListener(Event.COMPLETE, completeF);

    button1.addEventListener(MouseEvent.CLICK,button1F);

    tbutton2.addEventListener(MouseEvent.CLICK,button1F)

    function button1F(e:MouseEvent):void{

    if(e.currentTarget.name.indexOf('1')){

    vidIndex=0;

    } else {

    vidIndex=1;

    }

    subIndex=0;

    video.source=videoA[vidIndex][subIndex];

    }

    function completeF(e:Event):void{

    subIndex++;

    if(subIndex<videoA[vidIndex].length){

    video.source=videoA[vidIndex][subIndex];

    } else {

    // do whatever

    }

    }

    1 reply

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    December 26, 2016

    stop();

    var videoA:Array=[ ['01A.flv','01B.flv','01C.flv'], ['02A.flv,'02B.flv'] ];

    var vidIndex:int;

    var subIndex:int;

    video.autoPlay = true;

    video.addEventListener(Event.COMPLETE, completeF);

    button1.addEventListener(MouseEvent.CLICK,button1F);

    tbutton2.addEventListener(MouseEvent.CLICK,button1F)

    function button1F(e:MouseEvent):void{

    if(e.currentTarget.name.indexOf('1')){

    vidIndex=0;

    } else {

    vidIndex=1;

    }

    subIndex=0;

    video.source=videoA[vidIndex][subIndex];

    }

    function completeF(e:Event):void{

    subIndex++;

    if(subIndex<videoA[vidIndex].length){

    video.source=videoA[vidIndex][subIndex];

    } else {

    // do whatever

    }

    }

    adilCAuthor
    Participant
    December 27, 2016

    kglad it was very helpful thank you

    i wrote it as follows.

    but when i click  button "two " 3 videos play 2A , 2B and 1C?

    and when i click button "three" 2 videos play 3 and 1C?

    also i want to my video player to be off when finishing the videos

    1C

    2B

    3

    I hope i made my point. Thank you

     

      

    stop();

    zero.addEventListener(MouseEvent.CLICK,zero1)

    function zero1(e:MouseEvent):void{

    gotoAndStop(1)

    }

    stop();

    var videoA:Array=[ ['01A.flv','01B.flv','01C.flv'],[ ] ];

    var vidIndex:int;

    var subIndex:int;

    vidPlayer.autoPlay = true;

    vidPlayer.addEventListener(Event.COMPLETE, completeF);

    one.addEventListener(MouseEvent.CLICK,vid1);

    function vid1(e:MouseEvent):void{

    if(e.currentTarget.name.indexOf('1')){

    vidIndex=0;

    } else {

    vidIndex=1;

    }

    subIndex=0;

    vidPlayer.source=videoA[vidIndex][subIndex];

    }

    one.addEventListener(MouseEvent.CLICK,d1)

    function d1(e:MouseEvent):void{

    gotoAndStop(2)

    }

    function completeF(e:Event):void{

    subIndex++;

    if(subIndex<videoA[vidIndex].length){

    vidPlayer.source=videoA[vidIndex][subIndex];

    } else {

    }

    }

    stop();

    var videoB:Array=[ [ '02A.flv','02B.flv'], [] ];

    var vidIndex2:int;

    var subIndex2:int;

    vidPlayer.autoPlay = true;

    vidPlayer.addEventListener(Event.COMPLETE, completeF2);

    two.addEventListener(MouseEvent.CLICK,vid2);

    function vid2(e:MouseEvent):void{

    if(e.currentTarget.name.indexOf('2')){

    vidIndex2=0;

    } else {

    vidIndex2=1;

    }

    subIndex2=0;

    vidPlayer.source=videoB[vidIndex2][subIndex2];

    }

    two.addEventListener(MouseEvent.CLICK,d2)

    function d2(e:MouseEvent):void{

    gotoAndStop(2)

    }

    function completeF2(e:Event):void{

    subIndex2++;

    if(subIndex2<videoB[vidIndex2].length){

    vidPlayer.source=videoB[vidIndex2][subIndex2];

    } else {

    }

    }

    stop();

    three.addEventListener(MouseEvent.CLICK, vid3);

    function vid3(event:MouseEvent):void

    {

    vidPlayer.source = "03.flv";

    }

    three.addEventListener(MouseEvent.CLICK,d3)

    function d3(e:MouseEvent):void{

    gotoAndStop(2)

    }

    kglad
    Community Expert
    Community Expert
    December 27, 2016

    copy and paste the code i suggested.  adjust videoA per your needs:

    var videoA:Array=[ [array of videos played by button 1], [array of videos played by button2], ...,[array of videos played by your last button] ];