pbj2Base64
♥0 |
Line 41 |
Modified 2009-06-27 13:41:44 |
MIT License
archived:2017-03-30 12:08:51
ActionScript3 source code
/**
* Copyright zahir ( http://wonderfl.net/user/zahir )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/wjVu
*/
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="465" width="465" backgroundColor="#CCCCCC">
<mx:Script>
<![CDATA[
import mx.utils.Base64Encoder;
private var f:FileReference;
private var ff:Array = [ new FileFilter("pbj File (*.pbj)", "*.pbj") ];
private function load():void{
f = new FileReference();
f.addEventListener(Event.SELECT, onSelect_pbj);
f.browse( ff );
}
private function onSelect_pbj(e:Event):void{
f.removeEventListener(Event.SELECT, onSelect_pbj);
f.addEventListener(Event.COMPLETE, onComp_pbj );
f.load();
}
private function onComp_pbj(e:Event):void{
var enc:Base64Encoder = new Base64Encoder();
enc.encodeBytes( f.data );
var str:String = enc.toString();
var str2:String = "";
for(var i:int=0, len:int = str.length; i<len; i++){
var sub:String = str.substr( i, 1 );
if(br.selected && sub == "\n" ){
sub = "\"\n+\"";
}else if(!br.selected && sub =="\n"){
continue
}
str2 += sub;
}
str = str2;
txt.text = "\"" + str + "\"";
}
]]>
</mx:Script>
<mx:Button x="10" y="4" label="pbj Load" click="load()"/>
<mx:TextArea x="10" y="30" width="445" height="425" id="txt" wordWrap="{wrap.selected}"/>
<mx:CheckBox x="92" y="4" label="折り返し" id="wrap" click="txt.wordWrap = wrap.selected"/>
<mx:CheckBox x="160" y="4" label="改行" id="br"/>
</mx:Application>