[英]Flash CS5: AS3 - remove ending of swf file?
我在Flash中制作了一個由於某種原因損壞的視頻,因此fla不再可用。 除了重新制作視頻外,我還想剪掉我發布的.swf文件的結尾,然后在結束播放后立即播放第二個.swf文件(帶有重播按鈕和指向特定網站的鏈接)
我的問題是:最后我可以將.swf削減大約3秒鍾嗎?
假設這是基於幀的動畫或swf,則在加載swf時,可以使用MovieClip(mySwf).currentScene.numFrames獲得幀的總數。 因此,您需要減少3秒的方式是根據當前幀率計算3秒有多少幀,然后在ENTER_FRAME回調中檢查currentFrame並在檢測到等於(總幀數減去3秒的值)時采取行動幀)。 代碼如下:
* 注意:代碼已編輯,請參見注釋 *
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();
}
}
代碼是我的頭上問題,但是至少,如果它還不能按原樣工作,那么您應該對概念有足夠的了解,以使其能夠正常工作或實現。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.