flash on 2010-11-13

by aruerula
http://www40.atwiki.jp/spellbound/pages/165.html
import flash.system.Security;
♥0 | Line 32 | Modified 2010-11-17 00:56:31 | MIT License
play

ActionScript3 source code

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

package
{
    //http://www40.atwiki.jp/spellbound/pages/165.html
    
    import flash.display.Sprite;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.display.Loader;
    import flash.events.Event;
    import flash.geom.Matrix;
    import flash.net.URLRequest;
    import flash.system.LoaderContext;
    //import flash.system.Security;
 
    public class Main extends Sprite
    {
        private const WIDTH:int = 100; // 幅
        private const HEIGHT:int = 100; // 高さ
 
        public function Main()
        {
            //Security.loadPolicyFile("http://farm3.static.flickr.com/crossdomain.xml");
            var loader:Loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
            loader.load(new URLRequest("http://a1.twimg.com/profile_images/1167468105/ProfilePhoto.png"), new LoaderContext(true)); // 読み込みたい画像URL
        }
 
        private function initHandler(event:Event):void
        {
            var loader:Loader = event.currentTarget.loader;
      
                var matrix:Matrix = new Matrix();
                matrix.scale(WIDTH / loader.width, HEIGHT / loader.height); // 設定したいサイズ / 元サイズ
     
                var bd:BitmapData = new BitmapData(WIDTH, HEIGHT); // 設定したいサイズ
                bd.draw(loader, matrix);
                addChild(new Bitmap(bd));
        }
    }
}