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

textPad

Get Adobe Flash player
by YAZUMA 13 Jul 2010
/**
 * Copyright YAZUMA ( http://wonderfl.net/user/YAZUMA )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6x8u
 */

package {
    import flash.system.*;
    import flash.display.*;
    import flash.text.*;
    import flash.events.*;
   import fl.controls.*;
   import flash.events.Event;
    import flash.net.FileReference;
    import mx.controls.Alert;

    [SWF(backgroundColor=0xffffff,width=500,height=500,frameRate=60)]
    
    public class sp extends Sprite {
        public var tf:TextField = new TextField;
        public var tf2:TextField = new TextField;
        private var pFileReference:FileReference;
        public function sp():void{
            System.useCodePage = true;
            tf.defaultTextFormat = new TextFormat("メイリオ", 16, 0xFF8C00, true);
            tf.type = "input";
            tf.multiline = true;
            tf.wordWrap = true;
            tf.useRichTextClipboard = true;
            tf.alwaysShowSelection = true;
            tf.mouseWheelEnabled = true;
            tf.antiAliasType = flash.text.AntiAliasType.ADVANCED;
            tf.background = true;
            tf.backgroundColor = 0xFFFFE0;
            tf.border = true;
            //tf.textColor = 0x1E90FF;
            tf.borderColor = 0xFFDEAD;
            tf.width = 480;
            tf.height = 400;
            tf.x = 10;
            tf.y = 50;
            addChild(tf);
            tf2.defaultTextFormat = new TextFormat("メイリオ", 30, 0x0, true);
            tf2.antiAliasType = flash.text.AntiAliasType.ADVANCED;
            tf2.width = 250;
            tf2.height = 45;
            tf2.x = 5;
            tf2.y = 5;
            tf2.text = "てきすと Pad。";
            addChild(tf2);
            var button:CustomSimpleButton = new CustomSimpleButton(10, 460, 20, 465, "Load");
            button.addEventListener(MouseEvent.CLICK, buttonClick);
            addChild(button);
            var button2:CustomSimpleButton = new CustomSimpleButton(100, 460, 110, 465, "Save");
            button2.addEventListener(MouseEvent.CLICK, buttonClick2);
            addChild(button2);
        }
        private function buttonClick(e:MouseEvent):void{
            var button:Button = e.target as Button;
            open_file();
        }
        private function buttonClick2(e:MouseEvent):void{
            var button:Button = e.target as Button;
            pFileReference.save(pFileReference.data);
        }
        private function open_file():void{
            pFileReference = new FileReference();
            pFileReference.addEventListener(Event.SELECT, selectHandler);
            pFileReference.addEventListener(Event.COMPLETE, loadCompleteHandler);
            pFileReference.addEventListener(Event.CANCEL, cancelHandler);
            pFileReference.addEventListener(Event.OPEN, openHandler);
            pFileReference.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            pFileReference.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            pFileReference.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            pFileReference.browse();
        }
        private function selectHandler(event:Event):void{
            FileReference(event.target).load();
        }
        private function loadCompleteHandler(e:Event):void{
            tf.text = String(pFileReference.data);
            for(var i:int = 0;i < tf.length; i++){
                if(tf.text[i] == "\n"){
                    tf.appendText(""+i);
                }
            }
        }
        private function cancelHandler(event:Event):void {
        }
        private function ioErrorHandler(event:IOErrorEvent):void {
        }
        private function openHandler(event:Event):void {
        }
        private function progressHandler(event:ProgressEvent):void {
        }
        private function securityErrorHandler(event:SecurityErrorEvent):void {
        }
    }
    
}
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.display.Shape;
import flash.display.SimpleButton;

class CustomSimpleButton extends SimpleButton {
    private var upColor:uint   = 0x32CD32;//0xff8c00;
    private var overColor:uint = 0xff4500;
    private var downColor:uint = 0x8b3626;
    private var size:uint      = 70;

    public function CustomSimpleButton(x:int, y:int, xx:int, yy:int, name:String) {
        downState      = new ButtonDisplayState(downColor, size, x, y, xx, yy, name);
        overState      = new ButtonDisplayState(overColor, size, x, y, xx, yy, name);
        upState        = new ButtonDisplayState(upColor, size, x, y, xx, yy, name);
        hitTestState   = new ButtonDisplayState(upColor, size, x, y, xx, yy, name);
        hitTestState.x = -(size / 10);
        hitTestState.y = hitTestState.x;
        useHandCursor  = true;
    }
}
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;

class ButtonDisplayState extends Sprite {
    private var bgColor:uint;
    private var size:uint;

    public function ButtonDisplayState(bgColor:uint, size:uint, x:int, y:int, xx:int, yy:int, name:String) {
        this.bgColor = bgColor;
        this.size    = size;
        draw(x, y, xx, yy, name);
    }

    private function draw(x:int, y:int, xx:int, yy:int, name:String):void {
        graphics.lineStyle(2, bgColor);
        graphics.beginFill(0xffffff);
        graphics.drawRoundRect(x, y, size, size/2, 15);
        graphics.endFill();
        
        var tf:TextField = new TextField();
        tf.defaultTextFormat = new TextFormat("_typeWriter", 20, bgColor, true);
        tf.text = name;
        tf.autoSize = "left";
        tf.x = xx;
        tf.y = yy;
        tf.selectable = false;
        addChild(tf);

    }
}