当前位置: 首页 > 工具软件 > CircleSlider > 使用案例 >

Flash与组件:CircleSlider

徐瀚
2023-12-01
  今晚是2010年最后一天,要跟随地球重新开始新的一年。一直以来很喜欢kp 的那套min组件,目前还没有能力去完成一套完整的组件,只是想做一点实验而已。太多实验需要去写,有时候有很多很多想法,只是很希望每一个程序都写得有用一些。未来的日子来,会细心修改之前写过的程序。好吧,新的一年要更加努力去完善这些实验。还有很多很多实验需要动手去做。
  今天晚上就写了一个之前projectMa的其中一个圆形交互图形。我并没有参考他的例子来写,只是凭自己的想法去实现,等完善之后将继续跟进这些实验。
  好,休息去~新年快乐!
  
  //0-360度组件 //用于调节360度对象使用 //version 1.0 //author 夏天的树人 package org.summerTree.components { import flash.display.Sprite; import flash.events.*; import flash.display.DisplayObjectContainer; import flash.display.Shape; import flash.filters.*; import flash.geom.*; import flash.filters.BevelFilter; import flash.text.*; public class CircleSlider extends Sprite { private var values:Number = 0; private var minValue:Number = 0; private var maxValue:Number = 100; private var out_radius:Number=40; private var in_radius:Number=15; private var bar_control:Sprite; private var bottom:Shape; private var msg:TextField = new TextField(); public function CircleSlider(parent:DisplayObjectContainer=null,mi nValue:Number=0,maxValue:Number=360) { this.minValue = minValue; this.maxValue = maxValue; if(parent==null) { addEventListener(Event.ADDED_TO_STAGE,init); } else { parent.parent.addChild(this); init(); } } private function init(event:Event=null):void { removeEventListener(Event.ADDED_TO_STAGE,init); addChildren(); } private function addChildren():void { bottom = new Shape(); addChild(bottom); bottom.graphics.beginFill(0xFFFFFF); bottom.graphics.drawCircle(0,0,out_radius); bottom.graphics.drawCircle(0,0,in_radius); bottom.graphics.endFill(); //发光滤镜; bottom.filters = [getFilter()]; bar_control = new Sprite(); bar_control.buttonMode = true; bar_control.x = 0; bar_control.y = -(out_radius+in_radius)*0.5; addChild(bar_control); bar_control.graphics.beginFill(0x999999); bar_control.graphics.drawCircle(0,0,6); bar_control.graphics.endFill(); bar_control.addEventListener(MouseEvent.MOUSE_DOWN ,onStaDragHandler); bar_control.addEventListener(MouseEvent.MOUSE_OVER ,onMouseOverHandler); bar_control.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutHandler); bar_control.stage.addEventListener(MouseEvent.MOUS E_UP,onStopDragHandler); } private function onStaDragHandler(event:MouseEvent):void { bar_control.stage.addEventListener(MouseEvent.MOUS E_MOVE,onMoveHandler); } private function onMouseOverHandler(event:MouseEvent):void { var myColor:ColorTransform = new ColorTransform(); myColor.color = 0x666666; bar_control.transform.colorTransform = myColor; } private function onMouseOutHandler(event:MouseEvent):void { var myColor:ColorTransform = new ColorTransform(); myColor.color = 0x999999; bar_control.transform.colorTransform = myColor; } private function onMoveHandler(event:MouseEvent):void { //编写控制的角度 var dy:Number = mouseY; var dx:Number = mouseX; var angle:Number = Math.atan2(dy,dx); var tempX:Number = (out_radius+in_radius)*0.5 * Math.cos(angle); var tempY:Number = (out_radius+in_radius)*0.5 * Math.sin(angle); bar_control.x = tempX; bar_control.y = tempY; if (bar_control.y <= 0 && bar_control.x < 0) { this.value = Math.round(angle * 180 / Math.PI + 450 / 360 * maxValue + minValue); } else { this.value = Math.round(angle * 180 / Math.PI + 90 / 360 * maxValue + minValue); } var evt:Event = new Event(Event.CHANGE); this.dispatchEvent(evt); } private function onStopDragHandler(event:MouseEvent):void { bar_control.stage.removeEventListener(MouseEvent.M OUSE_MOVE,onMoveHandler); } //设置拖动的值 public function set value(dataValue:Number):void { this.values = dataValue; } //返回拖动的值 public function get value():Number { return values; } //设置对象坐标 public function move(x:Number,y:Number):void { this.x = x; this.y = y; } //设置大小 public function setSize(out_radius:Number,in_radius:Number):void { this.out_radius=out_radius; this.in_radius=in_radius; bottom.graphics.clear(); bottom.graphics.beginFill(0xFFFFFF); bottom.graphics.drawCircle(0,0,out_radius); bottom.graphics.drawCircle(0,0,in_radius); bottom.graphics.endFill(); bottom.filters = [getFilter()]; this.bar_control.y=-0.5*(out_radius+in_radius); this.bar_control.x=0; } //返回滤镜 private function getFilter():GlowFilter { return new GlowFilter(0x999999,0.8,9); } } }
 类似资料: