Bounce og drag borders
Jeg har tidligere fået hjælp til et motion og bounce script(senedenstående).. nu er jeg rendt ind i 2 små problemer.
1) Min bounce, (som her er 50% og 100%).. bliver triggered ved at klikke på et movieclip.. kan triggere denne på en anden måde? Vil gerne have sat alle mine movieclips til størelse 50% ved start.. og så 100% når man klikker på knapperne.
2) Man kan hive rundt med diverse movieclips.. men hvad med en border som man ikke kan hive den ud fra? Hvordan og hvorledes?
flash fil kan findes på: www.4b4.dk/flash.fla
// definitioner af variabler for bevægelsesscriptet
followMouse(clip0,0.2,0.5)
followMouse(clip1,0.2,0.5)
followMouse(clip2,0.2,0.5)
followMouse(clip3,0.2,0.5)
// definitioner af variabler for bounce scriptet
setNewBounceButton(btn0, clip0);
setNewBounceButton(btn1, clip1);
setNewBounceButton(btn2, clip2);
setNewBounceButton(btn3, clip3);
// bevægelsesscript, mouseUp fixed
function followMouse(mc, physics0, physics1) {
mc.onPress = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
mc.pressed = true;
mc.swapDepths(++_root.topdepth);
mc.onEnterFrame = function() {
if (this.getDepth() == _root.topDepth) {
this.xspeed = ((_root._xmouse - this._x) * physics0) + (this.xspeed * physics1);
this.yspeed = ((_root._ymouse - this._y) * physics0) + (this.yspeed * physics1);
this._x += this.xspeed;
this._y += this.yspeed;
}
};
}
};
mc.onMouseUp = function() {
if (!mc.pressed) {
return;
}
mc.pressed = false;
mc.x = _xmouse;
mc.y = _ymouse;
mc.onEnterFrame = function() {
this.xspeed = ((this.x - this._x) * physics0) + (this.xspeed * physics1);
this.yspeed = ((this.y - this._y) * physics0) + (this.yspeed * physics1);
this._x += this.xspeed;
this._y += this.yspeed;
if (Math.max(Math.max(Math.abs(this.x - this._x), Math.abs(this.y - this._y)), Math.max(Math.abs(this.xspeed), Math.abs(this.yspeed))) < 0.2) {
this._y = this.x;
this._y = this.y;
delete this.onEnterFrame;
}
};
};
}
// bounce script
MovieClip.prototype.elasticScale = function(target, accel, convert) {
if (this.$_step == undefined) this.$_step = 0;
this.$_step = this.$_step * accel + (target - this._xscale) * convert;
this._xscale = this._yscale += this.$_step
this.swapDepths(++_root.topdepth);
}
function setBounce(clip, b) {
clip.current_bounce = b;
clip.onEnterFrame = bounce;
}
function bounce() {
this.elasticScale(this.current_bounce, .5, .6);
if (Math.min(Math.abs(this.current_bounce - this._xscale),Math.abs(this.$_step)) < 0.1) {
delete this.onEnterFrame;
}
}
function bounceButton() { // funktion til knapper
setBounce(this.clip, (this.bounce = !this.bounce) ? 50 : 100);
}
function setNewBounceButton(btn, clip) {
btn.onRelease = bounceButton;
btn.clip = clip;
btn.bounce = false;
}
