2013-08-21 45 views
1

我真的需要一些AS3脚本来运行某些功能,当我离开特定帧时。退出帧后Flash AS3运行函数

我的理由是把一些功能停止视频,并恢复我的MP3播放器的声音后,我退出包含FLV播放帧。


我使用这个脚本,它在FLash投影机中很好用,但stage.invalidate();导致像Swfkit和Zinc这样的第三方应用程序制造商在我尝试退出flv播放帧后没有响应。

这里是我的脚本:

stage.invalidate(); 

mene.addEventListener(Event.RENDER,exitingF); 
mene.addEventListener(Event.REMOVED_FROM_STAGE, removedF); 

function exitingF(e:Event):void{ 

      controller.gotoAndStop(2); 
      pausePosition = sndChannel.position; 
      sndChannel.stop(); 
      isPlaying = false; 
} 


function removedF(e:Event):void{ 
      mene.stop(); 
      controller.gotoAndStop(1); 
      sndChannel = soundClip.play(pausePosition); 
      isPlaying = true; 
} 

所有我需要的是一些另一种说法退出Flash specfic帧之后运行一些脚本(去另一帧)

回答

0

尝试使用addFrameScript()功能。

它的工作原理就像这样:OBJECT.addFrameScript(FRAME, CALLBACK)

这将脚本添加到时间线上。只要达到指定的帧回调将被执行。

下面是一个例子,我发现:http://blog.newmovieclip.com/2007/04/30/add-a-frame-script-addframescript-dynamically-in-flash-cs3/

package com.newmovieclip{ 
import flash.display.MovieClip; 
public class Main extends MovieClip { 
public var myStar:Star; 
     //constructor 
public function Main() { 
    //place a star on stage 
    myStar = new Star(); 
    addChild(myStar); 
    //add script to star timeline on frame 5 
    myStar.addFrameScript(4,frameFunction); // (zero based) 
} 
private function frameFunction():void { 
    trace("Executing code for star Frame 5"); 
    //delete frame script by passing null as second parameter 
    myStar.addFrameScript(4,null); 
     } 
} 
} 

记住帧0基于以上,在例如内嵌评论中提及

+0

真的感谢答复,但你能解释我更多有关这个脚本,即时通讯真的很成熟在AS3 是这个脚本可以用于我的理由?因为我想在退出框架后添加脚本,而不是输入框架 – Arioman

+0

当然,我已经更新了我的答案 – Helto

+0

看来addFrameScript()是一个功能,允许您将动作添加到特定的框架,我该如何使用此功能对于退出框架? 我有各种各样的菜单,他们每个链接到各种帧 – Arioman