可以通过JavaScript控制SWF? [英] Possible to control SWF through Javascript?

查看:104
本文介绍了可以通过JavaScript控制SWF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的情况:

客户希望一个循环的SWF文件暂停两秒钟之后,开始播放一遍(这是一个很好的构建动画的一个标志,但标志不会在屏幕上停留很长时间,因为电影的重复,这样用户才无法看清标识为长。这是无关紧要的,但良好的背景故事。)

Client wants a looping SWF file to pause for two seconds before it begins playing all over again (it's a nice build animation on a logo, but the logo doesn't stay on the screen for very long because the movie repeats so users can't see the logo for long. This is irrelevant, but good back story.)

他们为我提供了一个SWF文件,而不是FLA。当我要求FLA我被告知,包含FLA坠毁的硬盘驱动器,它不能被检索到。所以,这是pretty的多一条死胡同。

They provided me with a SWF file, but not FLA. When I asked for the FLA I was told the hard drive that contained the FLA crashed and it cannot be retrieved. So, that is pretty much a dead-end.

在我去尝试去编译SWF和所有有趣的东西,我想知道是否有什么办法,这可以用HTML和Javascript完成。那就是:

Before I go and try to de-compile the SWF and all that fun stuff, I wanted to know if there was any way that this could be done with HTML and Javascript. That is:

  1. 有SWF环
  2. 暂停电影两秒钟,它重新启动之前

你怎么看?

推荐答案

这是不可能轻易地用JavaScript,但如果你加载的swf到另一个swf这是很容易的。然后,您可以访问原来的SWF的主时间轴和你能控制它。如果你想控制一个电影叫targetMovie.swf你可以做这样的事情:

This isn't easily possible with javascript, but it is very easy if you load the swf into another swf. You then have access to the main timeline of the original swf and you'd be able to control it. If you want to control a movie called targetMovie.swf you can do something like this:

var loader:Loader = new Loader();
loader.load(new URLRequest("targetMovie.swf"));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
addChild(loader);

var logoMovie:MovieClip;
function onComplete(evt:Event):void{
    logoMovie = MovieClip(loader.content);
    // call pauseMovie at end of timeline
    logoMovie.addFrameScript(logoMovie.totalFrames-1, pauseMovie);
}
function pauseMovie():void{
    logoMovie.stop();
    // delay for two seconds;
    setTimeout(function(){
      logoMovie.play();   
        }, 2000);
}

我上传了一些源文件,这里这里

这篇关于可以通过JavaScript控制SWF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆