简体   繁体   English

onLoadComplete不适用于通过AS3加载的AS2 SWF

[英]onLoadComplete not working with AS2 SWF loaded via AS3

So I have run into an issue and I think it is mostly because I haven't worked with as2 in about 5 years so things are pretty hazy. 所以我遇到了一个问题,我认为这主要是因为我大约5年没有使用过as2了,所以情况非常朦胧。 Anyway, my problem is that I need to display PDF files within the flash movie. 无论如何,我的问题是我需要在Flash电影中显示PDF文件。 To do so I have resorted to running SWFTools in my backend and converting pdfs to swf for display. 为此,我不得不在后端运行SWFTools并将pdf转换为swf进行显示。 SWFTools, though, outputs AS2 files which I can load into AS3 but I can't actually control (for example, calling stop()). 但是,SWFTools输出可以加载到AS3但实际上无法控制的AS2文件(例如,调用stop())。

Thus I have resorted to using an AS2 loader which gets loaded into the AS3 project which is responsible for loading the converted pdf swfs. 因此,我求助于使用AS2加载器,该加载器被加载到AS3项目中,该项目负责加载转换后的pdf swfs。 The problem I am running into is that the listener does not seem to be firing when I load the AS2 file in via AS3 but it fires just fine when run on it's own. 我遇到的问题是,当我通过AS3加载AS2文件时,侦听器似乎未启动,但是当它自己运行时,它会正常启动。

This is the code I am running. 这是我正在运行的代码。 To summarize when I run this code on it's own "LOADED" correctly prints to the output and the loaded SWF stops. 总结一下,当我自行运行此代码时,“ LOADED”将正确输出到输出,并且已加载的SWF停止。 However, when I run it via an AS3 container the swf loads in correctly but the "LOADED" trace never occurs and the stop is not executed. 但是,当我通过AS3容器运行它时,swf会正确加载,但是永远不会发生“ LOADED”跟踪,也不会执行停止。

thanks so much for any help! 非常感谢您的帮助!

var loader:MovieClipLoader

var listener =  new Object();
listener.onLoadComplete = function(loadedClip) {
    trace("LOADED");
    loadedClip.stop();
}

loadFile("data/testing.swf");

function loadFile(target){
    loader = new MovieClipLoader();
    loader.addListener(listener);
    loader.loadClip(target, holder_mc);
}

SWF Tools does support AS3, you need to change it in the options. SWF工具确实支持AS3,您需要在选项中进行更改。

1. Open your PDF in swf tools
2. Edit=>Options
3. Viewer tab
4. Check "No viewer" and flash version 9. (Or use the simple viewer) 
    - You can also do the "Insert stop after each frame"

I know this because I've done the same thing with a PDF. 我知道这一点是因为我对PDF所做的相同。 If you don't have those options, then it's time to download the latest version! 如果您没有这些选项,那么该下载最新版本了!

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

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