別ドメインの外部画像を読み込む

by ProjectNya
セキュリティサンドボックス侵害エラーが出て、
画像のサイズがリサイズ(100*100)にならない。
♥0 | Line 27 | Modified 2011-03-10 18:35:33 | MIT License
play

ActionScript3 source code

/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/xnTu
 */

////////////////////////////////////////////////////////////////////////////////
// 別ドメインの外部画像を読み込む
////////////////////////////////////////////////////////////////////////////////

package {

    import flash.display.Sprite;
    import flash.display.Loader;
    import flash.events.Event;
    import flash.net.URLRequest;

    [SWF(backgroundColor="#EEEEEE", width="465", height="465", frameRate="30")]

    public class Main extends Sprite {
        private var photoPath:String = "http://www.project-nya.jp/test/photo.jpg";
        private var loader:Loader;

        public function Main() {
            //Wonderfl.capture_delay(1);
            init();
        }

        private function init():void {
            graphics.beginFill(0xEEEEEE);
            graphics.drawRect(0, 0, 465, 465);
            graphics.endFill();
            //
            loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
            loader.load(new URLRequest(photoPath));
            addChild(loader);
        }
        private function complete(evt:Event):void {
            evt.target.content.width = 100;
            evt.target.content.height = 100;
        }
        
    }

}

Forked