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

エンコードテスト

Get Adobe Flash player
by teageek 14 Sep 2009
    Embed
/**
 * Copyright teageek ( http://wonderfl.net/user/teageek )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7Ib1
 */

package {
    import flash.display.Sprite;
    import flash.utils.*;
    import flash.text.*;
    import flash.ui.*;
    import flash.events.*;
    import com.bit101.components.*;

    
    public class FlashTest extends Sprite {
 
            //元の文字列 
            private var url:String = "http://test.com/test.cgi?hoge=0&lan=jp";
            private var f:Array=[encodeURI,encodeURIComponent,escape,escapeMultiByte];
            private var fn:Array=["encodeURI","encodeURIComponent","escape","escapeMultiByte"];
            private var f2:Array=[decodeURI,decodeURIComponent,unescape,unescapeMultiByte];
            private var fn2:Array=["decodeURI","decodeURIComponent","unescape","unescapeMultiByte"];
            private var tf:TextField= new TextField();
            private var tf2:TextField= new TextField();
            private var radio1:RadioButton;
            private var radio2:RadioButton;
            private var inputText:InputText; 
            private var inputText2:InputText; 

            public function FlashTest(){
                    var panel:Panel = new Panel(this, stage.stageWidth *.1, stage.stageHeight *.1);
                    panel.setSize(stage.stageWidth *0.8, stage.stageHeight *0.8);

                    var pushbutton:PushButton = new PushButton(panel, 220, 15);
                    pushbutton.label = "Try";
                    pushbutton.width = 100;
                    pushbutton.addEventListener(MouseEvent.CLICK,encode);
                    
                    inputText = new InputText(panel, 20, 40);
                    inputText.text = url;
                    inputText.width=330;
                    inputText.addEventListener(Event.CHANGE,encode);
                    
                    inputText2 = new InputText(panel, 20, 60);
                    inputText2.text = "Input Text";
                    inputText2.width=330;
                    inputText2.height=300;
                    tf2.addEventListener(Event.CHANGE,encode);
                    
                    radio1 = new RadioButton(panel, 20, 20);
                    radio1.label = "encode";
                    radio1.selected=true;
                    radio2= new RadioButton(panel, 120, 20);
                    radio2.label = "decode";
                    
                    encode();   
                }
            public function encode(e:Event=null):void{
                    var d:Array=new Array();var dn:Array=new Array();
                    inputText2.text=""; 
                    if(radio1.selected)d=f,dn=fn;
                    if(radio2.selected)d=f2,dn=fn2;
                    
                    d.map(function(x:*,index:int, ...rest):void { 
                        inputText2.text+=((dn[index].toString())+"\n")
                        inputText2.text+=((x(inputText.text))+"\n\n") });
         
                
                }
    }
}