textfiled选装

 package
{
        import flash.display.Sprite;
        import flash.events.MouseEvent;
        import flash.text.TextField;
        import flash.text.TextFormat;
        /**
        * ...
        * @author FLASH023
        */
        public class Main extends Sprite
        {
                private var now_box:TextBox;
                public function Main():void {
                        var _p:int = 12;
                        while (_p--) {
                                var _box:TextBox  = new TextBox ();
                                _box.x = 100+Math.random () * 550;
                                _box.y = 100 + Math.random () * 400;
                                _box.rotationZ = Math.random () * 360;
                                _box.addEventListener (MouseEvent.CLICK, onClick);
                                addChild (_box);
                        }
                }
                private function onClick(_evt:MouseEvent ):void {
                        var _box:TextBox = _evt.target as TextBox;
                        if (_box) {
                                now_box&&(now_box.focus  = false);
                                _box.focus = true;                               
                                now_box = _box;
                        }
                }
        }
        }
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.text.TextField;
        import flash.events.MouseEvent;
        class TextBox extends Sprite {
                private var r_btn:Sprite;
                private var p_txt:TextField;
                public function TextBox():void {
                        p_txt = addChild (new TextField) as TextField ;
                        p_txt.autoSize = "left";
                        p_txt.text = "测试文本";
                        p_txt.selectable = false;
                        p_txt.mouseEnabled = false;
                        p_txt.x = width * -.5;
                        p_txt.y = height * -.5;
                        p_txt.borderColor = 0x333399;
                        r_btn = addChild (new Sprite) as Sprite;
                        r_btn.graphics.beginFill (0x333399,.6);
                        r_btn.graphics.drawCircle (0, 0, 5);
                        r_btn.x = p_txt.width * .5;
                        r_btn.y = -p_txt.height * .5;
                        r_btn.visible = false;
                        r_btn.buttonMode = true;
                        addEventListener (MouseEvent.MOUSE_DOWN, mouseDown );
                }
                private function mouseDown(_evt:MouseEvent ):void {
                        if (_evt.target != r_btn) {
                                startDrag ();
                        }else{
                                addEventListener (Event.ENTER_FRAME, startRing );
                        }
                        stage.addEventListener (MouseEvent.MOUSE_UP, mouseUp);
                }
                private function startRing(_evt:Event):void {
                        rotationZ = Math.atan2 (parent.mouseY - y, parent.mouseX - x) / Math.PI * 180;
                }
                private function mouseUp(_evt:MouseEvent ):void {
                        stopDrag();
                        removeEventListener (Event.ENTER_FRAME, startRing );
                        stage.removeEventListener (MouseEvent.MOUSE_UP, mouseUp);
                }
                public function set focus(_b:Boolean):void {
                        r_btn.visible = _b;
                        p_txt.border = _b;
                }
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值