简体   繁体   English

Flash CS5:AS3-删除SWF文件的结尾?

[英]Flash CS5: AS3 - remove ending of swf file?

I made a video in flash which somehow got corrupted, so the fla is no longer usable. 我在Flash中制作了一个由于某种原因损坏的视频,因此fla不再可用。 Instead of remaking the video, I would like to just snip off the end of the .swf that I published and then probably just play a second .swf immediately after to end it (with replay buttons and a link to a particular website) 除了重新制作视频外,我还想剪掉我发布的.swf文件的结尾,然后在结束播放后立即播放第二个.swf文件(带有重播按钮和指向特定网站的链接)

My question is: Is it possible for me to cut the .swf by about 3 seconds at the end? 我的问题是:最后我可以将.swf削减大约3秒钟吗?

Assuming this is a frame-based animation or swf, when you load the swf you can get the total number of frames using MovieClip(mySwf).currentScene.numFrames. 假设这是基于帧的动画或swf,则在加载swf时,可以使用MovieClip(mySwf).currentScene.numFrames获得帧的总数。 So the way you would shave off 3 seconds would be to work out how many frames 3 seconds would be based on the current framerate, then inside an ENTER_FRAME callback check the currentFrame and act when you detect it is equal to (totalFrames less 3 seconds worth of frames). 因此,您需要减少3秒的方式是根据当前帧率计算3秒有多少帧,然后在ENTER_FRAME回调中检查currentFrame并在检测到等于(总帧数减去3秒的值)时采取行动帧)。 The code looks like: 代码如下:

* Note: Code edited, see comments * * 注意:代码已编辑,请参见注释 *

var mySwf:MovieClip;
var reducedTotalFrames:int;

var clipLoader:Loader = new Loader();
clipLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
clipLoader.load(new URLRequest("http://www.mysite.com/mySwf.swf"));

function loadComplete(e:Event):void
{
     mySwf = LoaderInfo(e.currentTarget).content as MovieClip;

     var totalFrameCount:int = mySwf.currentScene.numFrames;

     var secondsToSubtract:int = 3;

     var threeSecondFrameCount:int = (stage.frameRate * secondsToSubtract);

     reducedTotalFrames = totalFrameCount - threeSecondFrameCount;

     stage.addEventListener(Event.ENTER_FRAME, onRender);

     stage.addChild(mySwf);

     mySwf.gotoAndPlay(1);
}

function onRender(e:Event):void
{
     if(mySwf != null && mySwf.currentFrame >= reducedTotalFrames){
          //This is the end of the SWF with 3 seconds trimmed off. Here we can stop play
          stage.removeEventListener(Event.ENTER_FRAME, onRender);
          mySwf.stop();
          doSomethingElse();
     }
}

Code is off the top of my head but at the very least, if it doesn't already work as-is, you should have a solid enough understanding of the concept to make it work or implement it as you see fit. 代码是我的头上问题,但是至少,如果它还不能按原样工作,那么您应该对概念有足够的了解,以使其能够正常工作或实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM