diff options
Diffstat (limited to 'bPod/com/player')
| -rw-r--r-- | bPod/com/player/Player.as | 131 | ||||
| -rw-r--r-- | bPod/com/player/Visuals.as | 85 |
2 files changed, 216 insertions, 0 deletions
diff --git a/bPod/com/player/Player.as b/bPod/com/player/Player.as new file mode 100644 index 0000000..81acd3b --- /dev/null +++ b/bPod/com/player/Player.as @@ -0,0 +1,131 @@ +
+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);
+ }
+
+}
\ No newline at end of file diff --git a/bPod/com/player/Visuals.as b/bPod/com/player/Visuals.as new file mode 100644 index 0000000..2a4ac7b --- /dev/null +++ b/bPod/com/player/Visuals.as @@ -0,0 +1,85 @@ + + +class com.player.Visuals extends MovieClip { + +// private var theRoot:MovieClip; + private var numParticles:Number = 10; + private var minDist:Number = 50; + private var springAmount:Number = .001; + + private var vbounds:MovieClip; + + public function Visuals() {} + + public function init():Void + { + setMask (vbounds); + + for(var i:Number=0; i< numParticles;i++) { + var particle:MovieClip = this.attachMovie("particle", "p" + i, i); + particle._x = Math.random() * vbounds._width; + particle._y = Math.random() * vbounds._height; + particle.vx = Math.random() * 6 - 3; + particle.vy = Math.random() * 6 - 3; + particle._xscale = particle._yscale = 10 + Math.random() * 100; + particle.mass = particle._xscale / 100; + } + +// onEnterFrame = initAnimation; + + + } + + private function onEnterFrame():Void + { + for(var i:Number = 0;i<numParticles;i++) + { + var particle:MovieClip = this["p" + i]; + particle._x += particle.vx; + particle._y += particle.vy; + if(particle._x > vbounds._width) { + particle._x = vbounds._x; + } + else if(particle._x < -10) { + particle._x = vbounds._width; + } + if(particle._y > vbounds._height) { + particle._y = vbounds._y; + } + else if(particle._y < -46) { + particle._y = vbounds._height; + } + } + + clear(); + for(i=0;i<numParticles-1;i++) + { + var partA:MovieClip = this["p" + i]; + for(var j:Number = i+1;j<numParticles;j++) { + var partB:MovieClip = this["p" + j]; + spring(partA, partB); + } + } + } + + function spring(partA:MovieClip, partB:MovieClip):Void + { + var dx:Number = partB._x - partA._x; + var dy:Number = partB._y - partA._y; + var dist:Number = Math.sqrt(dx*dx + dy*dy); + if(dist < minDist) + { + lineStyle(1, 0xffffff, 100 - dist / minDist * 100); + moveTo(partA._x, partA._y); + lineTo(partB._x, partB._y); + var ax:Number = dx * springAmount; + var ay:Number = dy * springAmount; + partA.vx += ax / partA.mass; + partA.vy += ay / partA.mass; + partB.vx -= ax / partB.mass; + partB.vy -= ay / partB.mass; + } + } + + +};
\ No newline at end of file |
