Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Using an If Statement here...

    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
    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

    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() {
    		
    if "btn1" pressed
    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" pressed
    		btn3.tween("_y", btn3.originalY + 25, .5, "easeOutQuad");
    		btn4.tween("_y", btn4.originalY + 25, .5, "easeOutQuad");
    
    else "btn3" pressed
    		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...
    Last edited by tomyknoker; 03-27-2007 at 12:52 PM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •