Skip to main content
skysajedi
Known Participant
October 25, 2017
Answered

Looping Video Script Does Not Work, Help

  • October 25, 2017
  • 2 replies
  • 1124 views

Hello,

I have a video I am trying to loop.

I have created an Animate file from the ActionScript 3 in Animate, and I have saved it in the same folder that the video resides in.

I have taken a FLVplayback from the components window, and placed it on the stage of the file.

Here is the script I am using, but, it does not work. The video does not even play:

vidplay.source="testvid.mp4";

import fl.video.*;

function onFLVComplete(event:VideoEvent):void{

event.target.play()

}

player.addEventListener(VideoEvent.COMPLETE, onFLVComplete);

Can you let me know what I am doing wrong or, let me know how to change the script to accommodate a loop and allow the video to play? I am running Animate CC 2018.

Thank you,

Sky

    This topic has been closed for replies.
    Correct answer Nick Gioia

    Here. This Code should do it for you.

    import fl.video.*;

    instance_name_here.source="video_name_here.mp4";

    instance_name_here.addEventListener(Event.COMPLETE,completeF);

    function completeF(e:Event):void{

    instance_name_here.seek(0);

    instance_name_here.play();

    }

    2 replies

    Nick GioiaCommunity ExpertCorrect answer
    Community Expert
    October 25, 2017

    Here. This Code should do it for you.

    import fl.video.*;

    instance_name_here.source="video_name_here.mp4";

    instance_name_here.addEventListener(Event.COMPLETE,completeF);

    function completeF(e:Event):void{

    instance_name_here.seek(0);

    instance_name_here.play();

    }

    skysajedi
    skysajediAuthor
    Known Participant
    October 25, 2017

    import fl.video.*;

    vidplay.source="testvid.mp4";

    vidplay.addEventListener(Event.COMPLETE,completeF);

    function completeF(e:Event):void{

    vidplay.seek(0);

    vidplay.play();

    }

    Hi nickg28,

    THANK YOU, this works perfectly!!!

    However, on the LOOP, the video actually comes to a stop, then replays, so, I get this like "quick flash" where the video stops and starts. Is there anyway, with ActionScript to get a softer blend at the end of the video, so, when it LOOPs, it looks seamless?

    Thank you, again, for your help, really appreciated!

    Sky

    kglad
    Community Expert
    Community Expert
    October 25, 2017

    that's expected and there's no way (that i know of) to prevent that unless two flv players are used.  it's usually easier to edit the video so the end and beginning are not interrupted by that white flash (eg, fade from white at the start, fade to white at the end).

    kglad
    Community Expert
    Community Expert
    October 25, 2017

    to start you're using two different names for your flvplayback component, vidplay and player.

    it's not clear which, or even if either, is correct. 

    did you assign an instance name (in the properties panel) for your flv component?