文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>flash绘图api实现点选线

flash绘图api实现点选线

时间:2010-07-18  来源:superherosk123

package lib
{
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.filters.GlowFilter;
        import flash.geom.Point;

        public class PointSelectLine extends Sprite
        {
                private var shape:Sprite;
                private var color:uint;
                private var startPoint:Point;
                
                public function PointSelectLine()
                {
                        addEventListener(Event.ADDED_TO_STAGE,init);
                }
                private function init(e:Event):void{
                        stage.addEventListener(MouseEvent.MOUSE_UP,onUp);
                        stage.addEventListener(MouseEvent.MOUSE_DOWN,onDown);
                }
                private function onUp(e:MouseEvent):void{
                        stage.removeEventListener(MouseEvent.MOUSE_MOVE,onMove);
                }
                private function onDown(e:MouseEvent):void{
                        startPoint = new Point(stage.mouseX,stage.mouseY);
                        color = Math.random() * 0xffffff;
                        initShape();
                        stage.addEventListener(MouseEvent.MOUSE_MOVE,onMove);
                }
                private function onMove(e:MouseEvent):void{
                        shape.graphics.clear();
                        shape.graphics.lineStyle(3,color);
                        shape.graphics.moveTo(startPoint.x,startPoint.y);
                        shape.graphics.lineTo(stage.mouseX,stage.mouseY);
                }
                private function initShape():void{
                        shape = new Sprite();
                        addChild(shape);
                        shape.addEventListener(MouseEvent.CLICK,onClick);
                }
                private function onClick(e:MouseEvent):void{
                        if(e.target.filters.length==0){
                                e.target.filters = [new GlowFilter()];
                        }else{
                                e.target.filters = [];
                        }
                }
        }
}
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载