Created
October 20, 2011 14:18
-
-
Save phretor/1301250 to your computer and use it in GitHub Desktop.
Visualization of the migration screen of BURN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package DetailsPanel.MigrationChart | |
{ | |
import fl.transitions.Tween; | |
import fl.transitions.TweenEvent; | |
import fl.transitions.easing.*; | |
import flash.display.Sprite; | |
import flash.events.Event; | |
public class MigrationEdge extends Sprite | |
{ | |
private var startCoordinates:Array; | |
private var endCoordinates:Array; | |
private const color:uint = 0xF2F2F2; | |
private var edge:Sprite; | |
private var pulse:Sprite; | |
private var durationFactor:Number; | |
private var pulsationX:Tween; | |
private var pulsationY:Tween; | |
private const ALPHA_MIN:Number = 0.1; | |
public function MigrationEdge(start:Array, end:Array, compatibility:Number) | |
{ | |
startCoordinates = start; | |
endCoordinates = end; | |
durationFactor = compatibility; | |
super(); | |
drawEdge(); | |
drawPulse(); | |
setAlpha(compatibility); | |
createPulsation(); | |
} | |
private function setAlpha(value:Number):void{ | |
if(value > ALPHA_MIN){ | |
edge.alpha = value; | |
pulse.alpha = value; | |
} | |
else{ | |
edge.alpha = ALPHA_MIN; | |
pulse.alpha = ALPHA_MIN; | |
} | |
} | |
private function drawEdge():void{ | |
edge = new Sprite(); | |
edge.graphics.lineStyle(1,color); | |
edge.graphics.moveTo(0,0); | |
edge.graphics.lineTo(endCoordinates[0]-startCoordinates[0], endCoordinates[1]-startCoordinates[1]); | |
addChild(edge); | |
} | |
private function drawPulse():void{ | |
pulse = new Sprite(); | |
pulse.graphics.beginFill(color); | |
pulse.graphics.drawCircle(0,0,1.5); | |
pulse.graphics.endFill(); | |
addChild(pulse); | |
} | |
private function createPulsation():void{ | |
pulsationX = new Tween(pulse,"x", Strong.easeOut, 0, endCoordinates[0]-startCoordinates[0], duration(durationFactor),true); | |
pulsationY = new Tween(pulse,"y", Strong.easeOut, 0, endCoordinates[1]-startCoordinates[1], duration(durationFactor),true); | |
pulsationY.addEventListener(TweenEvent.MOTION_FINISH, restartTweens); | |
} | |
private function duration(x:Number):Number{ | |
return (1-x)*2.5 + 0.5; | |
} | |
private function restartTweens(_evt:TweenEvent):void{ | |
pulse.x = 0; | |
pulse.y = 0; | |
pulsationX = new Tween(pulse,"x", Strong.easeOut, 0, endCoordinates[0]-startCoordinates[0], duration(durationFactor),true); | |
pulsationY = new Tween(pulse,"y", Strong.easeOut, 0, endCoordinates[1]-startCoordinates[1], duration(durationFactor),true); | |
pulsationY.addEventListener(TweenEvent.MOTION_FINISH, restartTweens); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment