有没有办法向Swiffy添加JavaScript侦听器,以便检测动画何时完成? (在SWF转换为Swiffy之前不编辑FLA)
在AS3中,我使用了加载SWF。 JS中是否有这样的东西:
private function loadAnimationCompleteListener():void {
//add listener for when animation is complete
animation.addEventListener(Event.ENTER_FRAME, isAnimationComplete);
}
//tell me when the intro animation is complete
private function isAnimationComplete (e:Event):void {
if (e.target.currentFrame == e.target.totalFrames) {
//do something here
//remove listener
animation.removeEventListener(Event.ENTER_FRAME, isAnimationComplete);
}
}
答案 0 :(得分:1)
试试这个:
private function loadAnimationCompleteListener():void {
//add listener for when animation is complete
animation.addEventListener(Event.ENTER_FRAME, isAnimationComplete);
}
//tell me when the intro animation is complete
private function isAnimationComplete (e:Event):void {
if (e.target.currentFrame == e.target.totalFrames) {
//do something here
navigateToURL(new URLRequest("alert('animation complete.')"), "_self");
//remove listener
animation.removeEventListener(Event.ENTER_FRAME, isAnimationComplete);
}
}
只需将alert
替换为js中的任何内容。