-
-
Save lionelB/4663836 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
drag = 0; | |
logo.swapDepths(20); | |
MovieClip.prototype.bounceInit = function(id) { | |
this.accel =0.7; | |
this.convert = 1.5; | |
this.xpos = 0; | |
this.toX = this.sx=this._x; | |
this.ypos = 0; | |
this.toY = this.sy=this._y; | |
this.r = 10; | |
this.isDrag=false; | |
this.son = new Sound(this); | |
this.son.attachSound("snd"+(this._name).substr(1,1)); | |
}; | |
function bounce() { | |
if (this.hitTest(_root._xmouse, _root._ymouse, true) and drag<2) { | |
if (!this.isDrag){ | |
drag++; | |
this.isDrag = true; | |
this.swapDepths(11); | |
} | |
var dx = _xmouse-this.sx; | |
var dy = _ymouse-this.sy; | |
this.toX = _xmouse-(dx/this.r); | |
this.toY = _ymouse-(dy/this.r); | |
} else { | |
if (this.isDrag){ | |
drag--; | |
this.isDrag = false; | |
this.son.setVolume(50); | |
this.son.start(); | |
this.swapDepths(0); | |
} | |
this.toX = this.sx; | |
this.toY = this.sy; | |
} | |
this.xpos = (this.xpos*this.accel)+((this.toX-this._x)*this.convert); | |
this._x = this._x+this.xpos; | |
this.ypos = (this.ypos*this.accel)+((this.toY-this._y)*this.convert); | |
this._y = this._y+this.ypos; | |
lineBounce(this._name,this.sx,0,this.sy); | |
} | |
function lineBounce(mcName,sx,sy,fil) { | |
var mc = this[mcName]; | |
var line = this["fil_"+mcName]; | |
var dx = sx - mc._x; | |
var dy = sy - mc._y; | |
var dist = Math.sqrt((dx*dx)+(dy*dy)); | |
if (dist>fil) { | |
with (line) { | |
clear(); | |
lineStyle(2, 0, 100); | |
moveTo(mc._x, mc._y); | |
lineTo(sx, sy); | |
} | |
} else { | |
with (line) { | |
clear(); | |
lineStyle(2, 0, 100); | |
moveTo(mc._x, mc._y); | |
var midx = (mc._x+sx)/2; | |
var midy = (mc._y+sy)/2; | |
curveTo(midx, midy+(fil*1.5-dist), sx, sy); | |
} | |
} | |
} | |
var mcs = new Array("l1", "l2", "l3", "l4", "l5", "l6", "l7"); | |
for (i in mcs) { | |
var mc = this[mcs[i]]; | |
mc.bounceInit(); | |
mc.onEnterFrame = bounce; | |
var line = this.createEmptyMovieClip("fil_"+mc._name, 10+i); | |
mc.swapDepths(line); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment