Hi guys,
Got this issue on some code here:
I’m trying to build a nav bar with 3 buttons, using only 1 frame, and no tweens, as only.
The wanted efect I can achive with 2 buttons:
With the 3 buttons I get this:
What I want is: a button can only became active (going up) when all other buttons are inactive (down).
In this last example some buttons don’t wait until other buttons are inactive, they become active right away!
In this last example using the 3 buttons I use this code:
MovieClip.prototype.multiProp = function(proper, posv, smooth) {
this.onEnterFrame = function() {
this[proper] -= (this[proper]-posv)/smooth;
};
};
startv = 300;
targetv = 61;
smoothness = 10;
properts = "_y";
mc_1.onRelease = function() {
if (Math.round(this[properts]) == startv) {
bt_mc1 = "up";
if (bt_mc2 == "up") {
mc_2.multiProp([properts], startv, smoothness);
this.onEnterFrame = function() {
if (Math.round(mc_2[properts]) == startv) {
this.multiProp([properts], targetv, smoothness);
}
};
}
if (bt_mc3 == "up") {
mc_3.multiProp([properts], startv, smoothness);
this.onEnterFrame = function() {
if (Math.round(mc_3[properts]) == startv) {
this.multiProp([properts], targetv, smoothness);
}
};
} else {
this.multiProp([properts], targetv, smoothness);
}
}
if (Math.round(this[properts]) == targetv) {
this.multiProp([properts], startv, smoothness);
}
};
mc_2.onRelease = function() {
if (Math.round(this[properts]) == startv) {
bt_mc2 = "up";
if (bt_mc1 == "up") {
mc_1.multiProp([properts], startv, smoothness);
this.onEnterFrame = function() {
if (Math.round(mc_1[properts]) == startv) {
this.multiProp([properts], targetv, smoothness);
}
};
}
if (bt_mc3 == "up") {
mc_3.multiProp([properts], startv, smoothness);
this.onEnterFrame = function() {
if (Math.round(mc_3[properts]) == startv) {
this.multiProp([properts], targetv, smoothness);
}
};
} else {
this.multiProp([properts], targetv, smoothness);
}
}
if (Math.round(this[properts]) == targetv) {
this.multiProp([properts], startv, smoothness);
}
};
mc_3.onRelease = function() {
if (Math.round(this[properts]) == startv) {
bt_mc3 = "up";
if (bt_mc1 == "up") {
mc_1.multiProp([properts], startv, smoothness);
this.onEnterFrame = function() {
if (Math.round(mc_1[properts]) == startv) {
this.multiProp([properts], targetv, smoothness);
}
};
}
if (bt_mc2 == "up") {
mc_2.multiProp([properts], startv, smoothness);
this.onEnterFrame = function() {
if (Math.round(mc_2[properts]) == startv) {
this.multiProp([properts], targetv, smoothness);
}
};
} else {
this.multiProp([properts], targetv, smoothness);
}
}
if (Math.round(this[properts]) == targetv) {
this.multiProp([properts], startv, smoothness);
}
};
Any idea why this doesn’t work as it should?
Oh… and by the way, is there anyway of achieving the same effect with less code? I guess I used too much code here, making it complex for me to work on.
Thank you!
