4 Replies Latest reply on Mar 20, 2011 6:29 PM by kglad-zqbLf4

    Loop a Video

    Mikesa3 Level 1

      Hi,

       

      I have tried to loop a video. Though in the SWF, the video plays only once.

       

      Can someone see something wrong in the AS3 code below (relevant info tagged like this --->)

       

      (FLV instance is called "Film_mc")

       

      Many thanks

       

       

       

       

      import flash.display.StageScaleMode;
      import flash.display.StageAlign;
      import flash.events.Event;
      ---> import fl.video.*;


      stage.scaleMode = StageScaleMode.NO_SCALE;
      stage.align = StageAlign.TOP_LEFT;

       

      // stage listeners
      stage.addEventListener(Event.RESIZE, resizeHandler);

       

      // rewind  video + listener
      ---> Film_mc.autoRewind = true;
      ---> Film_mc.addEventListener(VideoEvent.AUTO_REWOUND, rewind, false, 0, true);

       

      // initialize sizing function
      resizeHandler (null);

       

      // aligningmovie clip with stage
      Film_mc.x = 0;
      Film_mc.y = 0;

       

      //calculating the original movie aspect ratio
      var originalfilmwidth:Number = Film_mc.width;
      var originalfilmheight:Number = Film_mc.height;
      var originalratio:Number = originalfilmwidth/originalfilmheight;

       

      // resizing

      var sw:Number = stage.stageWidth;
      var sh:Number = stage.stageHeight;
      trace(originalratio);
      var ratio:Number = sw/sh;
      trace(ratio);
      if (ratio>=originalratio)
      {
        Film_mc.width=sw;
        Film_mc.height=sw/originalratio;
      }  else 
      {
        Film_mc.height=sh;
        Film_mc.width=sh*originalratio;
      }

       

      function resizeHandler (event:Event):void
      {
      var sw:Number = stage.stageWidth;
      var sh:Number = stage.stageHeight;
      trace(originalratio);
      var ratio:Number = sw/sh;
      trace(ratio);
      if (ratio>=originalratio)
      {
        Film_mc.width=sw;
        Film_mc.height=sw/originalratio;
      }  else 
      {
        Film_mc.height=sh;
        Film_mc.width=sh*originalratio;
      }

       

      }


      // video rewind

      ---> function rewind(event:VideoEvent):void {
      ---> Film_mc.play();
      ---> }