Index: lams_tool_mindmap/src/flash/AS/Design.as =================================================================== diff -u -re28d61401c1f05f1b3db8068f7ad76f161e90f09 -r643162984254c265d82c6c6d5f2ff34c378e1ce4 --- lams_tool_mindmap/src/flash/AS/Design.as (.../Design.as) (revision e28d61401c1f05f1b3db8068f7ad76f161e90f09) +++ lams_tool_mindmap/src/flash/AS/Design.as (.../Design.as) (revision 643162984254c265d82c6c6d5f2ff34c378e1ce4) @@ -5,10 +5,12 @@ import flash.geom.*; import flash.errors.*; import flash.utils.*; + import zoomer.*; public class Design extends Sprite { + protected static var MIN_SCALE:Number = 0.4; + protected static var MAX_SCALE:Number = 2.5; protected var mindMap:MindMap; protected var frame:WhiteFrame; - protected var edgeOutline:Sprite; protected var navigationBar:Sprite; protected var navigate:Boolean; protected var moving:Boolean; @@ -17,6 +19,8 @@ protected var toolTip:ToolTip; protected var connectionIcon:ConnectionIcon; protected var ground:Sprite; + protected var zoomControl:Zoomer; + protected var zooming:Number; public function Design(mindMap:MindMap, world:Stage) { this.ground = new Sprite(); this.ground.graphics.beginFill(0,0); @@ -40,13 +44,10 @@ this.frame.addEventListener(MouseEvent.MOUSE_OVER, onNavigationHover); this.frame.addEventListener(MouseEvent.MOUSE_OUT, onNavigationOut); this.indicator = new ArrowHead(); + this.indicator.addEventListener(MouseEvent.CLICK, this.onIndicatorClick); this.navigationBar = new Sprite(); this.navigationBar.addChild(this.frame); this.navigationBar.addChild(this.indicator); - this.edgeOutline = new Sprite(); - this.edgeOutline.graphics.lineStyle(2, 0x888888); - this.edgeOutline.graphics.drawRect(0, 0, 800, 600); - this.navigationBar.addChild(this.edgeOutline); this.addChild(this.navigationBar); this.connectionIcon = new ConnectionIcon(); this.connectionIcon.y = 50; @@ -60,15 +61,56 @@ this.navigate = false; this.speedX = 0; this.speedY = 0; + this.zoomControl = new Zoomer(); + this.zoomControl.scaleX = this.zoomControl.scaleY = 28/Math.max(this.zoomControl.width, this.zoomControl.height); + this.addChild(this.zoomControl); + this.zoomControl.scaleX = this.zoomControl.scaleY = 1.3; + this.zoomControl.x = 400-this.zoomControl.width/2-this.zoomControl.getRect(this).left; + this.zoomControl.y = 600-this.zoomControl.getRect(this).bottom; + this.zoomControl.addEventListener(ZoomerEvent.ZOOM_IN, this.onStartZoomIn); + this.zoomControl.addEventListener(ZoomerEvent.ZOOM_OUT, this.onStartZoomOut); + this.zoomControl.addEventListener(ZoomerEvent.STOP_ZOOMING, this.onEndZooming); + this.zooming = 0; this.addEventListener(Event.ENTER_FRAME, onFrame); world.addChild(this); this.mindMap.addEventListener(InformationEvent.INFORMATION, onGetInfo); this.mindMap.addEventListener(InformationEvent.NO_INFORMATION, onNoInfo); try{ ExternalInterface.addCallback("getMindmap", this.toString); }catch(error:Error){ + } } + protected function indicate():void { + this.indicator.visible = true; + var dx:Number, dy:Number; + var tg:Number = (this.frame.width/2-this.mindMap.x)/(this.frame.height/2-this.mindMap.y); + if(Math.abs(tg) <= this.frame.width/this.frame.height){ + dy = this.frame.height/2 * (this.mindMap.y>this.frame.height/2?1:-1); + dx = tg*dy; + }else{ + dx = this.frame.width/2 * (this.mindMap.x>this.frame.width/2?1:-1); + if(tg == Number.POSITIVE_INFINITY){ + dy = 0; + }else dy = dx/tg; + } + var px:Number, py:Number; + px = this.frame.width/2+dx; + py = this.frame.height/2+dy; + var distance:Number = Point.distance(new Point(this.mindMap.x, this.mindMap.y), new Point(px, py)); + this.indicator.alpha = distance/500; + var ax:Number, ay:Number; + if(this.frame.height/2 != py){ + ay = 20*(this.frame.height/2-py)/Math.sqrt(Math.pow(this.frame.height/2-py,2)+Math.pow(this.frame.width/2-px,2)) + py; + ax = (ay-py)*(this.frame.width/2-px)/(this.frame.height/2-py)+px; + }else{ + ay = py; + ax = px+20*(pxthis.frame.width || this.mindMap.y<0 || this.mindMap.y>this.frame.height){ - this.indicator.visible = true; - var dx:Number, dy:Number; - var tg:Number = (this.frame.width/2-this.mindMap.x)/(this.frame.height/2-this.mindMap.y); - if(Math.abs(tg) <= this.frame.width/this.frame.height){ - dy = this.frame.height/2 * (this.mindMap.y>this.frame.height/2?1:-1); - dx = tg*dy; - }else{ - dx = this.frame.width/2 * (this.mindMap.x>this.frame.width/2?1:-1); - if(tg == Number.POSITIVE_INFINITY){ - dy = 0; - }else dy = dx/tg; - } - var px:Number, py:Number; - px = this.frame.width/2+dx; - py = this.frame.height/2+dy; - var distance:Number = Point.distance(new Point(this.mindMap.x, this.mindMap.y), new Point(px, py)); - this.indicator.alpha = distance/500; - var ax:Number, ay:Number; - if(this.frame.height/2 != py){ - ay = 20*(this.frame.height/2-py)/Math.sqrt(Math.pow(this.frame.height/2-py,2)+Math.pow(this.frame.width/2-px,2)) + py; - ax = (ay-py)*(this.frame.width/2-px)/(this.frame.height/2-py)+px; - }else{ - ay = py; - ax = px+20*(pxthis.frame.width || this.mindMap.y<0 || this.mindMap.y>this.frame.height){ + this.indicate(); }else{ - this.edgeOutline.visible = false; + this.indicator.visible = false; } } + protected function onIndicatorClick(event:MouseEvent):void { + this.mindMap.x = 400; + this.mindMap.y = 300; + } protected function onPressGround(event:MouseEvent):void { this.mindMap.startDrag(); } @@ -197,6 +215,15 @@ protected function onLeaveGround(event:MouseEvent):void { this.mindMap.stopDrag(); } + protected function onStartZoomIn(event:ZoomerEvent):void { + this.zooming = 1; + } + protected function onStartZoomOut(event:ZoomerEvent):void { + this.zooming = -1; + } + protected function onEndZooming(event:ZoomerEvent):void { + this.zooming = 0; + } protected function onWinServerResponse(event:ServerMindMapEvent):void { this.connectionIcon.incoming = true; }