装载机完整的事件不会与浏览器的工作(AS3) [英] Loader Complete event does not work with browser (AS3)

查看:97
本文介绍了装载机完整的事件不会与浏览器的工作(AS3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着去加载图像中的影片剪辑并更改其尺寸如下:

Im trying to load an image in a movie clip and change its size as follow:

    var loader:Loader = new Loader();

    public function setProfilePicture(url:String){
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplte);
        loader.load(new URLRequest(url));
        addChild(loader);
    }


    protected function onComplte(event:Event):void
    {
        EventDispatcher(event.target).removeEventListener(event.type, arguments.callee);
        var image:DisplayObject = (event.target as LoaderInfo).content;
        image.width = 132;
        image.height = 132;

    }

在code以上正常工作时,我在Adobe Flash CS5执行它,但是当我尝试用一​​个浏览器(如浏览器)打开它,图像的大小不会更改为132x132。我试图把的addChild(装载机)中的onComplete的功能,但在这个时候,我用浏览器打开它时,图像不会连装,而在Adobe Flash CS5执行像以前一样保持。

The code above works fine when I execute it with adobe flash CS5, but when I try to open it with a browser (e.g. Chrome), the size of images does not change to 132x132. I tried to put addChild(loader) in the onComplete function, but in this time when I open it with a browser, the image won't be even loaded, while executing with adobe flash CS5 remains as before.

我的建议是,当我们通过浏览器打开,该函数的onComplete不工作,但为什么??? 任何想法将AP preciated。

My suggestion is that when we open it by browser, the function onComplete does not work, but WHY??? Any idea will be appreciated.

推荐答案

试试这个黑客:

protected function onComplte( event:Event ):void {
    EventDispatcher( event.target ).removeEventListener( event.type, arguments.callee );

    var loaderInfo:LoaderInfo = LoaderInfo( event.target );
    loaderInfo.loader.scaleX = 132 / loaderInfo.width;
    loaderInfo.loader.scaleY = 132 / loaderInfo.height;
}

这篇关于装载机完整的事件不会与浏览器的工作(AS3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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