In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

TestFileReference(NG Version???)

あれ?Wonderflでやるとうまくいくのはなぜ…><。
Get Adobe Flash player
by yd_niku 15 Feb 2009
    Embed
// あれ?Wonderflでやるとうまくいくのはなぜ…><。
package {
        import flash.events.*;
	import flash.display.Sprite;
	public class TestFileReference extends Sprite {
		public function TestFileReference() {
                    var btn:Sprite = new LabelButton( "Download" );
                    btn.x = btn.y = 20;
                    addChild( btn );
                    btn.addEventListener( MouseEvent.CLICK, testDownload );
                }
                private function testDownload( e:Event ):void {
			new Download().test();
		}
	}
}

import flash.net.FileReference;
import flash.net.URLRequest;
class Download{
    public function Download() {
    }
    public function test():void {
        var fRef:FileReference = new FileReference();
	fRef.download(new URLRequest("http://level0.kayac.com/images/araga/valentine_2009/main.gif"), "valentine.gif" );
    }
}

import flash.display.*;
import flash.text.*;

class RectButton extends Sprite {
    public function RectButton( w:Number, h:Number, rcolor:uint= 0x00, ralpha:Number = 0.0 ) {
            buttonMode = true;
            useHandCursor = true;
            mouseChildren = false;
            graphics.beginFill(rcolor, rcolor);
            graphics.drawRect(0, 0, w, h );
            graphics.endFill();
    }
}
class LabelButton extends RectButton {
    public function LabelButton( textLabel :String ) {
            var t:TextField = new TextField();
            t.autoSize = TextFieldAutoSize.LEFT;
            t.text = textLabel;
            addChild( t );
            super( t.width, t.height, 0xFFFFF00 );
    }
}