PDA

View Full Version : How do i return a button to its normal state when another button is clicked?


Hillyhi11s
03-09-2007, 06:09 AM
Ok, in my main menu, I have a button that needs to lets say, expand onRollOver, jiggle onRelease, and retract once another button is clicked. Sounds easy enough. I got the first 2 no problemo. I just cant figure out how to tell it to go back to normal when another button is clicked. My button's timeline is like this:

1 15 20 35(gotoAndStop(1))
grow ----- click ------ shrink

those are my lables and the corresponding frames. I am telling the code right now to goto and play "grow" on rollover; and gotandplay "click" onRelease. So, how do I say, play "shrink" if another button is clicked?

My code is like this for one button so far. What do I need to add to make this work?

MM_designMC.onRollOver = function() {
_root.MM_designMC.gotoAndPlay("grow");
}
MM_designMC.onRelease = function() {
reActivateBtns();
_root.MM_designMC.gotoAndPlay("click");
this.enabled = false
_level0.myMCL.loadClip("design.swf", 5)
}
//this part is to enable and disable buttons once they are clicked.
function reActivateBtns() {
MM_mainMC.enabled = true;
MM_designMC.enabled = true;
MM_contactMC.enabled = true;
}

WhidbeyTomas
03-13-2007, 12:10 AM
Ok. I'm on a mission to stamp out mysteries. Since no one has replied to my question, I will respond to every other orphan question. I will do this until someone responds to mine. (I know this is a despicable form of terrorism, but what can I do?)

This is just me, but I think you are making this too complicated. I would generally have (at most) functionality for mouse-over and mouse out. In this case, I would add:


MM_designMC.onRollOut = function() {
_root.MM_designMC.gotoAndPlay("shrink");
}


But you are the master of your interface. One simple-minded way to handle this would be to create a boolian variable for each button indicating activity (e.g., var mybutton.Hot:String) Initialize all of these to 0 and then reset to 1 when the button is clicked and reset the variable for every other button to 0. This way an event listener could trigger movement if your button's Hot variable is toggled.

How's that?

Hillyhi11s
03-14-2007, 12:04 AM
Thanks for replying. I thought it was a lost cause.

So, I was thinking that too, assigning the boolean value then an if then statement for the buttons. The problem is... ummm... I don't know hot to write it. I am going though a book and it does not get that complicated. Can you help? maybe write one for a hypothetical button? :) :confused:

WhidbeyTomas
03-14-2007, 05:19 AM
I am about to sign-off for the day, but I will attach a button file I made for another user earlier today. This example is not the same as yours. The button in this case has a tween. But the function code is the same. In your case, you would add code on frame one that initializes your variables.

var but1:String=0;
var but2:String=0;
var but3:String=0;
var but4:String=0;

Then you will need a function code simular to the functions in the attached movie. You will want to add code that reinitializes the variables. Then each button should have an onEnterFrame handler that will tell the button to move to a particular frame if the variable ==0.

You will also need to set the variable to 1 in your onRollOver function.

See if any of this makes sense. Try something and zip it up and let me see it. Don't worry about doing things wrong, it is easier to help you if you are willing to make some effort.

I'll look for your effort tomorrow.

tg

Hillyhi11s
03-18-2007, 01:57 AM
Yeah, i see how those buttons work you sent me. Mine are a bit different. you can go to www.hillbdesign.com/index1.html There you can see what i am trying to get. The design button is the only one that has the teen applied to it as of right now. So, once it is clicked I want the branch to go back in (while the other branch grows out).

I am not sure how to write the code you were saying for me to do before. Seriously, I dont know much code at all! Its really best if you (or anyone else) could please spell it out for me. :rolleyes: Thanks so much,

Hope to hear from you soon,
H

WhidbeyTomas
03-20-2007, 10:22 PM
I can recommend books that work for me: ActionScript for Flash MX, Colin Moock (O'Reilly), Flash Hacks, Sham Bhangal, and Understanding Macromedia Flash 8: ActionScript2.

If I get more time, I'll see if I can do more.