TestFileReference(NG Version???)
あれ?Wonderflでやるとうまくいくのはなぜ…><。
// あれ?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 );
}
}