Results 1 to 2 of 2

Thread: Using an If Statement here...

  1. #1
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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" 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...
    Last edited by tomyknoker; 03-27-2007 at 11:51 AM.

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    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.

Bookmarks

Posting Permissions

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