Looping video with Flash CS4 Video Component

I got a demo requirement to have a video playing continuously within the Flash CS4 video component. I found that none of the skins include a loop button. Bummer. So I create one. Fortunately the video component has a video event call “autowound” which I can use to trigger the play method once the playhead has been rewind. Below is the code for you to try it out:

import fl.video.VideoEvent;

fl_video.autoRewind = true; // fl_video being the name of the video component

fl_video.addEventListener(VideoEvent.AUTO_REWOUND, doLoop);

function doLoop(e:VideoEvent):void
{
 e.target.play();
}

Advertisements

~ by brianchau on July 24, 2009.

19 Responses to “Looping video with Flash CS4 Video Component”

  1. you left out the function name:

    function doLoop(e:VideoEvent):void{
    e.target.play();
    }

  2. but a good quick tip nonetheless, thanks for sharing

  3. Thanks Rob. I have updated the post.

  4. Thank you thank you thank you—I really can’t tell you how much this has helped me. Simple, elegant & works perfectly.

  5. Nice.

    can you explain how to loop a video without the flv playback component ?

  6. Thanks, I will try to apply усебя.

  7. This works well, apart from what looks like a 1 frame shutter when it begins the loop again, unfortunately ruining the effect. Any ideas?

    Cheers,
    Dan

  8. Works perfectly!!!

  9. Should it work in CS3?

  10. Thank you very much for you code :). They works well!!! :))))))

  11. Hi, thank you so much,
    there is a lot of bad advice about this on other forums, good to see a nice simple solution,

    i modified your code a little bit, it seems to loop better but wouldn’t have been able to do it without your help

    import fl.video.VideoEvent;

    kniveVid.addEventListener(VideoEvent.COMPLETE, doLoop);

    function doLoop(e:VideoEvent):void
    {
    e.target.play();
    }

  12. Hey, I tried the code using Flash CS4, it doesn’t work… I guess I am just not using it the right way. Can you please help me?
    My flv ist called “xmas_2010_v2.flv” so I wrote “xmas_2010_v2” instead of “fl_video” in the code. It tells me: “access to undefined attribute / feature xmas_2010_v2”.
    Where do I have to place the code? I placed it in the first frame of my action line.
    Thanks soooo much for your help!!!

    • i will try and help,
      first, with the video name, thats fine as long as you name the video componant thing xmas_2010_v2 (in the in properties name box) and the video component is set up to
      load xmas_2010_v2.flv (in the component inspector or import wizard)

      where i would put the code is on the frame with the video component, sometimes its easy to make a new layer and make a keyframe for where you want the code so it doesn’t interupt other code.

      the code i would use would be

      import fl.video.VideoEvent;
      xmas_2010_v2.addEventListener(VideoEvent.COMPLETE, loopAction);
      function loopAction(e:VideoEvent):void
      {
      e.target.play();
      }

      • Hi Dylan,
        thank you for your quick answer. No bugs anymore 🙂 but the video still doesn’t loop.
        At the component insp the source is called xmas_2010_v2.m4v, property name is xmas_2010_v2, and I put your code in an extra layer with a keyframe right at the beginning of the time line…
        do I have to make the loop already in the movie before importing into flash?
        You can answer (if you want to) via e-mail cape-lioness@gmx.ch

        Greetings, Eva

      • Check out the free Adobe Flash Media Playback based on the OSMP. It has built-in features like Auto-Loop, among other things.

        http://www.adobe.com/products/flashmediaplayback/

  13. hmmm Im not really too sure. maybe you will need to do the code more like up the top of this thread, im using cs5 so it might be a bit different.

    Try putting the video in a new project with just one frame and use the code, that way you will be able to see if its the code and video causing you problems or something else in the video.

  14. thanks a lot!
    worked for me!

  15. Thanks, useful material. Has added your blog in bookmarks.
    Спасибо за совет, попробую применить у себя.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: