jennys26
01-18-2006, 10:24 PM
I have a tab with a slide out menu. The slide out menu is coded so that when you roll over it and it starts to slide out, if you take your mouse off before its finished sliding out, it will begin to slide back in at that point. It wont finish the whole sliding out animation.
So because of that I've ended up with all these hit tests and if else tests to get the buttons working. The code below works, but I've got 8 tabs and its ridiculous to write this out 8 times. Any ideas on how to compress this code??
tab_1.onRollOver = function () {
if(_currentFrame = 1){
tab_1.onEnterFrame = function () {
this.nextFrame();
if (this._currentframe >= 25) {
this.onEnterFrame=undefined
}
else if (tab_1.pmp_mc.hitTest(_xmouse,_ymouse)){
this.pmp_mc.gotoAndStop(2);
this.pap_mc.gotoAndStop(1);
this.ci_mc.gotoAndStop(1);
this.burns_mc.gotoAndStop(1);
}
else if (tab_1.pap_mc.hitTest(_xmouse,_ymouse)){
this.pap_mc.gotoAndStop(2);
this.pmp_mc.gotoAndStop(1);
this.ci_mc.gotoAndStop(1);
this.burns_mc.gotoAndStop(1);
}
else if (tab_1.ci_mc.hitTest(_xmouse,_ymouse)){
this.pap_mc.gotoAndStop(1);
this.pmp_mc.gotoAndStop(1);
this.ci_mc.gotoAndStop(2);
this.burns_mc.gotoAndStop(1);
}
else if (tab_1.burns_mc.hitTest(_xmouse,_ymouse)){
this.pap_mc.gotoAndStop(1);
this.pmp_mc.gotoAndStop(1);
this.ci_mc.gotoAndStop(1);
this.burns_mc.gotoAndStop(2);
}
else if (tab_1.blank_mc.hitTest(_xmouse,_ymouse)){
this.pap_mc.gotoAndStop(1);
this.pmp_mc.gotoAndStop(1);
this.ci_mc.gotoAndStop(1);
this.burns_mc.gotoAndStop(1);
}
}
}
}
tab_1.onRollOut = button.onDragOut = function () {
tab_1.onEnterFrame = function () {
this.prevFrame();
if (this._currentframe == 1) {
this.onEnterFrame=undefined}
}
}
tab_1.onPress = function () {
if (tab_1.pmp_mc.hitTest(_xmouse,_ymouse)){
this._parent.gotoAndStop("pmp");
}
if (tab_1.pap_mc.hitTest(_xmouse,_ymouse)){
trace("pap_mc onPress");
}
if (tab_1.ci_mc.hitTest(_xmouse,_ymouse)){
trace("ci_mc onPress");
}
if (tab_1.burns_mc.hitTest(_xmouse,_ymouse)){
trace("burns_mc onPress");
}
}
So because of that I've ended up with all these hit tests and if else tests to get the buttons working. The code below works, but I've got 8 tabs and its ridiculous to write this out 8 times. Any ideas on how to compress this code??
tab_1.onRollOver = function () {
if(_currentFrame = 1){
tab_1.onEnterFrame = function () {
this.nextFrame();
if (this._currentframe >= 25) {
this.onEnterFrame=undefined
}
else if (tab_1.pmp_mc.hitTest(_xmouse,_ymouse)){
this.pmp_mc.gotoAndStop(2);
this.pap_mc.gotoAndStop(1);
this.ci_mc.gotoAndStop(1);
this.burns_mc.gotoAndStop(1);
}
else if (tab_1.pap_mc.hitTest(_xmouse,_ymouse)){
this.pap_mc.gotoAndStop(2);
this.pmp_mc.gotoAndStop(1);
this.ci_mc.gotoAndStop(1);
this.burns_mc.gotoAndStop(1);
}
else if (tab_1.ci_mc.hitTest(_xmouse,_ymouse)){
this.pap_mc.gotoAndStop(1);
this.pmp_mc.gotoAndStop(1);
this.ci_mc.gotoAndStop(2);
this.burns_mc.gotoAndStop(1);
}
else if (tab_1.burns_mc.hitTest(_xmouse,_ymouse)){
this.pap_mc.gotoAndStop(1);
this.pmp_mc.gotoAndStop(1);
this.ci_mc.gotoAndStop(1);
this.burns_mc.gotoAndStop(2);
}
else if (tab_1.blank_mc.hitTest(_xmouse,_ymouse)){
this.pap_mc.gotoAndStop(1);
this.pmp_mc.gotoAndStop(1);
this.ci_mc.gotoAndStop(1);
this.burns_mc.gotoAndStop(1);
}
}
}
}
tab_1.onRollOut = button.onDragOut = function () {
tab_1.onEnterFrame = function () {
this.prevFrame();
if (this._currentframe == 1) {
this.onEnterFrame=undefined}
}
}
tab_1.onPress = function () {
if (tab_1.pmp_mc.hitTest(_xmouse,_ymouse)){
this._parent.gotoAndStop("pmp");
}
if (tab_1.pap_mc.hitTest(_xmouse,_ymouse)){
trace("pap_mc onPress");
}
if (tab_1.ci_mc.hitTest(_xmouse,_ymouse)){
trace("ci_mc onPress");
}
if (tab_1.burns_mc.hitTest(_xmouse,_ymouse)){
trace("burns_mc onPress");
}
}