flash on 2009-6-4
♥0 |
Line 59 |
Modified 2009-06-04 13:21:06 |
MIT License
archived:2017-03-20 03:23:10
ActionScript3 source code
/**
* Copyright hacker_n2ylj3ym ( http://wonderfl.net/user/hacker_n2ylj3ym )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/e0fC
*/
package {
import com.adobe.images.JPGEncoder;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.net.FileReference;
import flash.events.*;
import flash.net.FileReferenceList;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.utils.ByteArray;
public class Main extends Sprite{
private var txt:TextField;
public function Main() {
txt = new TextField();
txt.width = 300;
txt.multiline = true;
txt.text = "test";
txt.border = true;
txt.type = TextFieldType.INPUT;
txt.x = 20;
txt.y = 50;
addChild(txt);
var txtSave:TextField = new TextField();
CreateSaveButton(txtSave, "てgggggてす",20, 380 );
addChild( txtSave );
txtSave.addEventListener(MouseEvent.CLICK, SaveFile(SaveTXT, "test.txt"));
}
private function CreateSaveButton( button:TextField, bName:String , x:int, y:int) : void
{
button.text = bName;
button.y = 20;
button.x = 20;
button.width = 50;
button.height = 20;
button.background = true;
button.backgroundColor = 0x888888;
button.textColor =0x000000;
button.selectable = false;
}
private function SaveFile(encFunc:Function, fileName:String):Function {
return function(e:MouseEvent) : void
{
var ff:FileReference = new FileReference();
ff.addEventListener(Event.OPEN, function(e:Event):void { trace("open"); } );
ff.addEventListener(ProgressEvent.PROGRESS, function(e:ProgressEvent):void { trace("progress"); } );
ff.addEventListener(Event.COMPLETE, function(e:Event):void { trace("complete"); } );
ff.addEventListener(Event.CANCEL, function(e:Event):void { trace("cancel"); } );
ff.addEventListener(Event.SELECT, function(e:Event):void { trace("select"); } );
ff.addEventListener(IOErrorEvent.IO_ERROR, function(e:IOErrorEvent):void { trace("ioError"); } );
ff.save(encFunc(), fileName);
}
}
private function SaveTXT() : String
{
return txt.text;
}
}
}