# Critical \>\>\> ELSE STATEMENT ....AS 3.0

**URL:** <https://forum.kirupa.com/t/critical-else-statement-as-3-0/283888>\
**Category:** Uncategorized\
**Created:** [March 12, 2009, 4:11am UTC](https://forum.kirupa.com/t/critical-else-statement-as-3-0/283888 "2009-03-12T04:11:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xPINKMERCEDESx](https://avatars.discourse-cdn.com/v4/letter/x/73ab20/32.png) [@xPINKMERCEDESx](https://forum.kirupa.com/u/xPINKMERCEDESx)\
**Post date:** [March 12, 2009, 4:11am UTC](https://forum.kirupa.com/t/critical-else-statement-as-3-0/283888/1 "2009-03-12T04:11:35Z")

</div>

hey guys…having some trouble with my conditional statement.

I have six buttons on the stage. Now, when a user selects a button, I need the previously selected button to go to its “close” frame. As I have it now, when a user selects a button, ALL THE other buttons go to their “close” frame label when only the previous button that was open should go to its “close” frame.

here’s the code that works perfectly for me. I just need help only with the else statement :

// wild card var to hold what last movie was loaded  
var lastLoaded:\*;

var buttons\_array:Array=new Array(xadvertising,xbranding, xcatalog, xgraphics,xeditorial,xbio,xcontact);

for (var i:int=0; i\<buttons\_array.length; i++)  
{  
buttons\_array\*.mouseChildren=false;  
buttons\_array\*.buttonMode=true;  
buttons\_array\*.id=i;  
buttons\_array\*.addEventListener(MouseEvent.ROLL\_OVER, onRollover);  
buttons\_array\*.addEventListener(MouseEvent.ROLL\_OUT, onRollout);  
buttons\_array\*.addEventListener(MouseEvent.CLICK, buttonClicked);  
}

function onRollover(event:MouseEvent):void  
{  
event.target.gotoAndPlay(“open”);  
}

function onRollout(event:MouseEvent):void  
{  
event.target.gotoAndPlay(“close”);  
}

function buttonClicked(event:MouseEvent):void  
{  
buttonSelected(event.target.id);

```
if(event.target.name !=lastLoaded)

```

{  
lastLoaded=event.target.name;  
container.gotoAndPlay(“motivate”);  
}  
}

function buttonSelected(id:int):void  
{  
for (var i:int=0; i\<buttons\_array.length; i++)  
{  
if (i==id)  
{  
buttons\_array\*.gotoAndStop(“dock”);  
buttons\_array\*.buttonMode=false;  
buttons\_array\*.removeEventListener(MouseEvent.ROLL\_OVER, onRollover);  
buttons\_array\*.removeEventListener(MouseEvent.ROLL\_OUT, onRollout);  
buttons\_array\*.removeEventListener(MouseEvent.CLICK, buttonClicked);  
} _else {  
buttons\_array.gotoAndPlay(“close”);  
buttons\_array_.buttonMode=true;  
buttons\_array\*.addEventListener(MouseEvent.ROLL\_OVER, onRollover);  
buttons\_array\*.addEventListener(MouseEvent.ROLL\_OUT, onRollout);  
buttons\_array\*.addEventListener(MouseEvent.CLICK, buttonClicked);  
}\*\*\*  
}  
}

// function to call exchange movies  
function exchangeMovies():void  
{  
my\_loader.load(new URLRequest(lastLoaded+".swf"));  
}

thanks for any time…

x lisa x
