PDA

View Full Version : Controlling movieclips with an IF function



w9914420
December 6th, 2003, 05:06 PM
Hi all i got a slight problem

I have created 3 movieclip buttons which have a total of 3 states each
UP, OVER and Pressed.

What i am wanting to do is create a fuction that will change the state of an already pressed button back to its UP state. For example

Button one is press and will stay in its state untill button 2 or 3 are presses then it will revert back to its up state.

My way of tackling the problem was to target a frame in the movie clip that I wanted to change such as this:

on (rollOut) {
gotoAndPlay("ee");
}
on (press) {
gotoAndPlay("dd");
}
on (press) {
_root.jill.gotoAndPlay(52);
}

as you can see nothing to it. but I then released that when I had more than two buttons using this fuction it then became obsolete due to the fact that the button would play a portion of the frame that I did not want to appear on screen.

I am a newbie to flash so complex scripting was not an option for me. Im not sure on how to approch this. I think an if statement is what i am looking for but how would you apply to this.

I want a statement that basically says for e.g

If button 1 is on the pressed state then when button 2 or 3 are pressed revert back to your up state (Im guessing i would have to apply this to all 3 buttons).

Ok thats it, If any one as any idea to how I can solve this pain in the neck or if anyone could point to any online tutorials that relate to my problem that would be great.

Thanks

w9914420

i have also included a sample of what i am working on

norie
December 6th, 2003, 05:49 PM
check this out:

w9914420
December 6th, 2003, 07:00 PM
I think this might be it, I am going to implement this as bestas i can

norie your a star thanks for your help mate

w9914420
December 6th, 2003, 09:12 PM
Thanks for your help dude, i tried the code and it worked in switching between the two states but unfortunately that is not what im after

Imagine this senario

1. You have 4 Identicle Buttons based on the same movie clip but each as a different instance. e.g

button 1
button 2
button 3
button 4


you press one of the buttons (in this case we shall choose the button number 1) which stays in its press state for e.g

when its on the stage as normal its colour = Blue
when the mouse is over the button its colour = Green
when it is pressed it stays in this state and its colour = Red

ok so with have one pressed button which is red and stays red to indicate that the button as been pressed.

The user decides to choose another button to press (excluding the one that he as already pressed) in this case the user presses button number 4.

WHAT SHOULD HAPPEN NOW

when the user presses button 4 the state of button 1 should return to its normal condition which in this case would be the colour blue. This change should only effect the pressed button and all the other buttons should remain in their present state.

If I was to describe this in my own logic terms I would say this:

The button state of a pressed button should change when the user presses a different button. Regardless of which combination of buttons are pressed the pressed button state will cahnge to a normal instance no matter which of the remaining three you choose.

Thats Why I assumed that you would need and actonscript with if statements to make it work

I hope I have been more clear in my objective


w9914420

P.s Thankls again, i think it makes it more difficult when u have animated states

Maizoon
December 6th, 2003, 09:28 PM
Did you search the forums before asking this? I had a similiar problem not to long ago and it was answered here:

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=38756

Anyway, since your dealing with frames and not color. Change...

onRelease = function(){
for(i=0;i<10;i++){
myColor = new Color(["btn"+i]);
myColor.setRGB(0x000000);
}
myColor = new Color(this);
myColor.setRGB(0xFF0000);
}

to something more like

onRelease = function(){
for(i=0;i<10;i++){
gotoAndPlay("ee");

}
gotoAndPlay("dd");
}

or however you are doing things.

norie
December 6th, 2003, 09:39 PM
if you make a generic file and send it to me i'll be happy to get it exactly the way you want.