import mx.utils.Delegate; import com.services.BuckyServices; import mx.transitions.easing.*; import mx.transitions.Tween; class com.player.Player extends MovieClip { var songList:Array; public static var s:Sound; var currentSongTitle:String; var currentSongInfo:String; var backing:MovieClip; var collapseBtn:MovieClip; var infoBtn:MovieClip; var playPauseBtn:MovieClip; var collapsed:Boolean; var dragging:Boolean; var initted:Boolean; var infoState:Boolean; var isPlaying:Boolean; var title_txt:TextField; var initBacking:Number; var oldX:Number; var oldY:Number; public function Player() { initted = dragging = collapsed = infoState = useHandCursor = _focusrect = isPlaying = false; } public function init(_inObject:Object):Void { if (!initted) { var t:Tween = new Tween(this, "_y", Elastic.easeOut, _y, 120, 1, true); initted = true; } infoBtn.gotoAndStop ("info"); infoBtn._rotation = 0; infoState = false; collapseBtn.gotoAndStop ("collapse"); playPauseBtn.gotoAndStop ("pauseIcon"); isPlaying = true; currentSongTitle = _inObject.filename; title_txt.text = currentSongTitle; songList.push (_inObject.theURL); initBacking = backing._alpha; currentSongInfo = BuckyServices.activeKeyword + " > " + BuckyServices.activeThread; stopAllSounds(); s = new Sound(_root); s.loadSound ( _inObject.theURL , true ); s.start(); } private function doCollapse():Void { if (!collapsed) { oldX = _x; oldY = _y; var vFunc:Function = function () { var xTween = new Tween(this, "_x", Regular.easeOut, _x, 11, .2, true); var yTween = new Tween(this, "_y", Regular.easeOut, _y, 9, .2, true); collapsed = true; } var bTween = new Tween (collapseBtn, "_rotation", Regular.easeOut, collapseBtn._rotation, 90, .4, true); var rTween = new Tween (this, "_rotation", Regular.easeOut, _rotation, -90, .4, true); rTween.onMotionFinished = Delegate.create (this, vFunc); } else { var xTween = new Tween(this, "_x", Regular.easeOut, _x, oldX, .4, true); var bTween = new Tween (collapseBtn, "_rotation", Elastic.easeOut, collapseBtn._rotation, 0, .8, true); var yTween = new Tween(this, "_y", Regular.easeOut, _y, oldY, .4, true); rTween = new Tween (this, "_rotation", Regular.easeOut, _rotation, 0, .4, true); collapsed = false; } } private function doInfoBtn():Void { var r:Number = infoState == true ? 0 : 180; title_txt.text = infoState == true ? currentSongTitle : currentSongInfo; new Tween(infoBtn, "_rotation", Regular.easeOut, infoBtn._rotation, r, .4, true); infoState = !infoState; } private function doPlayPause():Void { if (isPlaying) { s.stop(); isPlaying = false; playPauseBtn.gotoAndStop ("playIcon"); } else { s.start(); isPlaying = true; playPauseBtn.gotoAndStop ("pauseIcon"); } } private function onPress():Void { if (collapseBtn.hitTest (_root._xmouse, _root._ymouse)) { doCollapse(); } else if (infoBtn.hitTest (_root._xmouse, _root._ymouse)) { doInfoBtn(); } else if (playPauseBtn.hitTest (_root._xmouse, _root._ymouse)) { doPlayPause(); } else { var aTween:Tween = new Tween(this, "_alpha", Regular.easeOut, _alpha, 20, .4, true); startDrag(this); } } private function onRelease():Void { stopDrag(); var aTween:Tween = new Tween(this, "_alpha", Regular.easeOut, _alpha, 100, .4, true); } }