加载外部 SWF 和最新版本的 FD

发布于 2024-10-28 20:50:39 字数 1435 浏览 3 评论 0原文

(我正在使用 FlashDevelop)

我在项目中加载一些外部 swf 时遇到问题。这一直很有效,直到几个月前他们将预加载器集成切换为:

[Frame(factoryClass="Preloader")]

从那以后,我用 Loader() 加载的 swf 就不再显示了。

知道发生了什么变化吗?

谢谢 !

代码:

public class Main extends Sprite 
{

    public function Main():void 
    {
        if (stage) init();
        else addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init(e:Event = null):void 
    {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        // entry point

        loadMovie("Dots.swf");
    }

    private function loadMovie(url:String):void {
        var mLoader:Loader = new Loader();

        mLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
        mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
        mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);

        mLoader.load(new URLRequest(url));
    }

    private function onCompleteHandler(loadEvent:Event):void {
        trace("COMPLETE");
        addChild(loadEvent.currentTarget.content);
    }

    private function onProgressHandler(event:ProgressEvent):void {
        trace("progressHandler: bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
    }

    private function ioErrorHandler (e:IOErrorEvent):void {
        trace("ERROR");
    }
}

(I'm working with FlashDevelop)

I'm having issue loading some external swfs in my project. This worked great until a few month back when they switched the preloader integration with :

[Frame(factoryClass="Preloader")]

Since then my swf loaded with a Loader() doesn't show.

Any idea of what changed ?

Thanks !

Code :

public class Main extends Sprite 
{

    public function Main():void 
    {
        if (stage) init();
        else addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init(e:Event = null):void 
    {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        // entry point

        loadMovie("Dots.swf");
    }

    private function loadMovie(url:String):void {
        var mLoader:Loader = new Loader();

        mLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
        mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
        mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);

        mLoader.load(new URLRequest(url));
    }

    private function onCompleteHandler(loadEvent:Event):void {
        trace("COMPLETE");
        addChild(loadEvent.currentTarget.content);
    }

    private function onProgressHandler(event:ProgressEvent):void {
        trace("progressHandler: bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
    }

    private function ioErrorHandler (e:IOErrorEvent):void {
        trace("ERROR");
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠檬 2024-11-04 20:50:39

“COMPLETE”是否已被查出?我无法从您在此处发布的代码中看出太多信息,可能还有其他情况发生,特别是在 Dots.swf 中。

我立即看到的一件事是,您的加载器对象可能正在被垃圾收集,但如果它正在追踪“完整”,则绝对不是这种情况。尝试立即将加载程序添加到显示列表中,看看是否会产生影响。例如:

var mLoader:Loader = new Loader();
addChild(mLoader);

我的所有工作都是在 Flash Develop 中完成的,并且没有遇到任何问题。如果您能够分享更多代码或示例项目,我可以进一步调查。

Is "COMPLETE" getting traced out? I can't tell too much from the code you posted here, there could be something else going on, particularly in Dots.swf.

The one thing I see right off the bat is that your loader object may be getting garbage collected, but if it is tracing out "COMPLETE" that definitely is not the case. Try adding loader to the display list right away and see if that makes a difference. eg:

var mLoader:Loader = new Loader();
addChild(mLoader);

I do all my work in Flash Develop and have not had any issues with this. If you are able to share more code, or example project, I could investigate further.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文