Join Login


Stock Photos from 123RF
 Closing Toggle Window when 1 opens
 by cdolphin09 - May 02, 2011

Hey Kevin.. or whomever else may know the answer to this :)

I have about 9 different toggle windows that open on my page with a corresponding button. When the user clicks on a button the toggle window will open and, it will close as well when the button is clicked again.
Instead of clicking the button again to close the window... I would like the user to click on any other toggle window button, so that a new window opens and at the same time the previous window closes.

Hope that makes sense.

Here is my script for a couple of the buttons... I am not sure where to even start to modify the script to what I would like as described above. I am suspecting that it would have to be a StopAll command so that when a new toggle window button is clicked, it stops all previous clips... I could be so wrong though.
-------

FP1btn.addEventListener(MouseEvent.CLICK, toggleContent1);
FP2Fbtn.addEventListener(MouseEvent.CLICK, toggleContent2);

function toggleContent1(event:MouseEvent){
if(event.target.name == "FP1btn"){
if(FP1window.currentFrame == 1){
FP1window.gotoAndPlay(2);
}
else{
FP1window.gotoAndPlay(12);}
}
}
function toggleContent2(event:MouseEvent){
if(event.target.name == "FP2btn"){
if(FP2window.currentFrame == 1){
FP2window.gotoAndPlay(2);
}
else{
FP2window.gotoAndPlay(12);}
}
}
--------

Thanks!
Cristina


cdolphin09
United States
Posts:19
Joined:Mar 28, 2011
 RE: Closing Toggle Window when 1 opens
 by RiverCityGraphix - May 02, 2011

I would think that if you add into the function of opening one button you could also add in code to close all the other ones.

So for the first button you would have:
FP1window.gotoAndPlay(2);
FP2window.gotoAndPlay(12);
FP3window.gotoAndPlay(12);
FP4window.gotoAndPlay(12);

That would be in the area that FP2window.gotoAndPlay(2); is currently. That way it would just open the one and close everything else.


Be sure to subscribe on YouTube.

Do you take great photos? Consider selling them on Dreamstime.
RiverCityGraphix
United States
Posts:327
Joined:Nov 21, 2009
 RE: Closing Toggle Window when 1 opens
 by cdolphin09 - May 03, 2011

Thank you! This worked :D
Although I did have to make a slight adjustment. I had to change each frame "12" to frame "24". At 12 it kept opening the toggle windows thinking it had to open them before closing them, since the toggle animation starts at 12 and ends at 24. When I put 24 into the script, it immediately closes each window upon pressing a button, which works just fine for me.
Thank you for your help!!
I couldn't be doing any of this without you!


cdolphin09
United States
Posts:19
Joined:Mar 28, 2011
 RE: Closing Toggle Window when 1 opens
 by RiverCityGraphix - May 03, 2011

Im glad you figured out that it would go to 24. Im glad it's all working for you now!


Be sure to subscribe on YouTube.

Do you take great photos? Consider selling them on Dreamstime.
RiverCityGraphix
United States
Posts:327
Joined:Nov 21, 2009
  
Home About Contact Forum Youtube Privacy Policy
Copyright © 2009-2011 RiverCityGraphix.All Rights Reserved.