0

I have several video files playing on the stage. I've converted them into movieclips so that I can scale and drag them by clicking. The problem is that I cannot loop them.

Then I tried to make them as SWF playback object's but after that my code wasn't working with them.

Next step was to make them Embedded video objects so that they loop automatically and the code is working. After that there appeared a problem that the objects are duplicating at some point.

Here's the original code as the videos are movieclips.

    var allDraggables:Array = new Array();
var mouseHold = false;
stage.addEventListener(MouseEvent.MOUSE_UP, mUp);

function mUp(MouseEvent)
{
 mouseHold = false;
}

function draggableObject(mc)
{
 var mouseOnThisObject = false;
 allDraggables.push(mc);
 mc.addEventListener(Event.ENTER_FRAME, drag);
 mc.addEventListener(MouseEvent.MOUSE_DOWN, mDown);
 function mDown(MouseEvent)
 {
  mouseHold = true;
  mouseOnThisObject = true;
 }

 function drag(MouseEvent)
 {

  if (mouseHold == true && mouseOnThisObject == true)
  {
   mc.addEventListener(Event.ENTER_FRAME, dragger);
  }

  if (mouseHold == false)
  {
   mc.removeEventListener(Event.ENTER_FRAME, dragger);
   mouseOnThisObject = false;
  }


 }

 mc.doubleClickEnabled = true;
mc.addEventListener(MouseEvent.DOUBLE_CLICK, scaleMe);

function scaleMe(e:MouseEvent)
{


if (e.target.scaleX < 2)
{
e.target.scaleX= e.target.scaleY = 2;
}
else (e.target.scaleX= e.target.scaleY = 1);
}




 function dragger(Event)
 {
  mc.x+=(mouseX-mc.x)/3;
  mc.y+=(mouseY-mc.y)/3;

  for (var i:int=0; i<allDraggables.length; i++){
  if(mc.hitTestObject(allDraggables[i]) && getChildIndex(allDraggables[i]) > getChildIndex(mc)){
   swapChildren(allDraggables[i], mc)
   }
  }
 }
}





draggableObject(green);
draggableObject(red);
draggableObject(video1);
draggableObject(video2);
draggableObject(video3);    
4

2 回答 2

0

我发现了一些我曾经在项目中使用过的旧代码,也许你可以试试这个。在我的 Flash 应用程序中它可以工作,尽管我没有将视频放入影片剪辑中。

import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.NetStatusEvent;

var nc:NetConnection = new NetConnection();

nc.connect(null);
ns = new NetStream(nc); 
ns.bufferTime = 10;

var vid:Video = new Video(1024,640);
vid.attachNetStream(ns);
addChild(vid);
ns.addEventListener(NetStatusEvent.NET_STATUS, ns_onPlayStatus)

function ns_onPlayStatus(event:NetStatusEvent):void {//loop video
    if(event.info.code == "NetStream.Play.Stop") {
        ns.seek(0);
    }
}
于 2012-07-02T17:52:18.177 回答
0

好吧,很难说出你到底尝试了什么,因为你还没有提供任何代码(还)..

但是,从我的脑海中,我认为这会奏效:

if(videoMC1.currentFrame == 250) { //put the number of the last frame of the movieclip in place of 250
   loopMC();
}
function loopMC() {
   videoMC1.stop();
   videoMC1.gotoAndPlay(1);
}

你在这里做的很简单;您检查传递/播放的当前帧,当它达到所需的数字(在您的情况下很可能是最后一帧)时,它会调用一个重置和播放视频的函数。

于 2012-07-02T13:29:55.227 回答