PDA

View Full Version : Using an If Statement here...



tomyknoker
03-27-2007, 11:21 AM
I have 5 buttons and the below code, basically the way it works is onRelease it send the playhead to a frame label. On rollOver it plays an animation, and onRollOut it reverses the animation. Works really well. The buttons all sit on top of each other, so when the first button is rollOver I need to move the others down, i.e. btn2, btn3, btn4. And if button 2 is rolled over I only need to move btn3 and btn4 (hopefully that makes sense) but the statement can't fit in with my code... Can I use an If somewhere? Can anyone see that working?

Current Code

numOfBtn = 5;
stop();
for (i=0; i<numOfBtn+1; i++) {
this["btn"+i].num = i;
this["btn"+i].onRelease = function() {
gotoAndStop("frm"+(this.num+1));
};
this["btn"+i].onRollOver = function() {
this.play();
};
this["btn"+i].onRollOut = function() {
this.onEnterFrame = function() {
if (this._currentframe != 1) {
this.prevFrame();
} else {
delete this.onEnterFrame;
}
};
};
}

Edited not written in code though



numOfBtn = 5;
stop();
for (i=0; i<numOfBtn+1; i++) {
this["btn"+i].num = i;
this["btn"+i].onRelease = function() {
gotoAndStop("frm"+(this.num+1));
};
this["btn"+i].onRollOver = function() {

if "btn1" rollOver
btn2.tween("_y", btn2.originalY + 25, .5, "easeOutQuad");
btn3.tween("_y", btn3.originalY + 25, .5, "easeOutQuad");
btn4.tween("_y", btn4.originalY + 25, .5, "easeOutQuad");

else "btn2" rollOver
btn3.tween("_y", btn3.originalY + 25, .5, "easeOutQuad");
btn4.tween("_y", btn4.originalY + 25, .5, "easeOutQuad");

else "btn3" rollOver
btn4.tween("_y", btn4.originalY + 25, .5, "easeOutQuad");

this.play();
};
this["btn"+i].onRollOut = function() {
this.onEnterFrame = function() {
if (this._currentframe != 1) {
this.prevFrame();
} else {
delete this.onEnterFrame;
}
};
};
}


If anyone can get that too work in code form would be much appreciated! Do I even have the right idea? I hope so...

Medyman
03-27-2007, 01:16 PM
You say that the buttons are on top of each other. Are you trying to click through btn1 to btn2, etc...

I don't know if thats possible as long as btn has onRollOver and onRollOut states.

If it were just when, i'd suggesting deleting the onRollOver state upon initiation which would allow interaction with the second layer, but thats not going to work if you have a onRollOut as well.