flash on 2012-4-10

by tepe
♥0 | Line 47 | Modified 2012-04-10 14:50:37 | MIT License
play

ActionScript3 source code

/**
 * Copyright tepe ( http://wonderfl.net/user/tepe )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/z9B9
 */

package {
    import flash.display.Sprite;
    import flash.net.*;
    import flash.text.*;
    import flash.events.*;
    public class FlashTest extends Sprite {
        private var so:SharedObject;
        private var t1:TextField = new TextField();
        public function FlashTest() {
            // write as3 code here..
            t1.border = true;
            t1.multiline = true;
            t1.type = "input";
            addChild(t1);
            t1.addEventListener(Event.CHANGE,onChange);
            so = SharedObject.getLocal("aaa");
            initBtn();
            if(so == null)t1.text = "error";
            else{
                if(so.data.text != undefined){
                    t1.text = so.data.text;
                }
            }
            
            
            
        }
        private function initBtn():void{
            var s:Sprite = new Sprite();
            s.graphics.beginFill(0xaaaaaa);
            s.graphics.drawCircle(0,0,20);
            s.graphics.endFill();
            addChild(s);
            s.x = 200;
            s.y = 50;
            var t2:TextField = new TextField();
            t2.text = "clear";
            t2.selectable = false;
            t2.x = -13;
            t2.y = -10;
            s.addChild(t2);  
            s.addEventListener(MouseEvent.CLICK,function():void{
                so.clear();
                t1.text = "";
            });
      
        }

        private function onChange(e:Event):void{
            so.data.text = t1.text;
        }

    }
}