# Auto adjustment (expand or collapse) of sub-buttons when clicked on the main button

**URL:** <https://forum.kirupa.com/t/auto-adjustment-expand-or-collapse-of-sub-buttons-when-clicked-on-the-main-button/330266>\
**Category:** flash\
**Created:** [December 21, 2012, 8:10am UTC](https://forum.kirupa.com/t/auto-adjustment-expand-or-collapse-of-sub-buttons-when-clicked-on-the-main-button/330266 "2012-12-21T08:10:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![learner\_7n](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@learner\_7n](https://forum.kirupa.com/u/learner_7n)\
**Post date:** [December 21, 2012, 8:10am UTC](https://forum.kirupa.com/t/auto-adjustment-expand-or-collapse-of-sub-buttons-when-clicked-on-the-main-button/330266/1 "2012-12-21T08:10:22Z")

</div>

Hi,

I have the following buttons and some sub buttons (Main buttons are in [COLOR=#0000ff]\*\*Blue \*\*[/COLOR]&[COLOR=#0000ff][/COLOR] Sub buttons are in [COLOR=#a52a2a]\*\*Brown \*\*[/COLOR]Color).[COLOR=#0000ff][/COLOR]

[COLOR=#0000ff] **Home** [/COLOR]  
[COLOR=#0000ff] **Schedule** [/COLOR]  
----[COLOR=#a52a2a] **Level-1** [/COLOR] [COLOR=#a52a2a] **Schedule** [/COLOR] \<Sub button of **Schedule** \>  
----[COLOR=#a52a2a] **Level-2** \*\*Schedule \*\*[/COLOR]\<Sub button of **Schedule** \>  
----[COLOR=#a52a2a] **Level-3** [/COLOR] [COLOR=#a52a2a] **Schedule** [/COLOR] \<Sub button of **Schedule** \>  
**[COLOR=#0000ff]EHSS  
[/COLOR]**----[COLOR=#a52a2a]\*\*Environment \*\*[/COLOR] \<Sub button of**EHSS**\>  
----[COLOR=#a52a2a]\*\*Health \*\*[/COLOR]\<Sub button of **EHSS** \>  
----[COLOR=#a52a2a]\*\*Safety \*\*[/COLOR] \<Sub button of **EHSS** \>  
----[COLOR=#a52a2a] **Security** [/COLOR]\<Sub button of **EHSS** \>  
\*\*[COLOR=#0000FF]Contacts

[/COLOR]\*\*Now the problem is, to make all the buttons auto adjustable when the button which has SUB Buttons clicked.  
**[COLOR=#0000FF][/COLOR]**  
What I mean is, First all the buttons on stage will be viewable as the following:  
[COLOR=#0000FF] **Home** [/COLOR]  
[COLOR=#0000FF] **Schedule** [/COLOR]  
\*\*[COLOR=#0000FF]EHSS  
[/COLOR]\*\*\*\*[COLOR=#0000FF]Contacts

[/COLOR]**But when I click on [COLOR=#0000FF][/COLOR][COLOR=#ff0000]Schedule[/COLOR], it should expand like the following:**[COLOR=#0000FF]  
[/COLOR]\*\*[COLOR=#0000FF] **Home** [/COLOR]  
[COLOR=#0000FF] **Schedule** [/COLOR]  
----[COLOR=#A52A2A] **Level-1** [/COLOR] [COLOR=#A52A2A] **Schedule** [/COLOR]  
----[COLOR=#A52A2A] **Level-2**  **Schedule** [/COLOR]  
----[COLOR=#A52A2A] **Level-3** [/COLOR] [COLOR=#A52A2A] **Schedule** [/COLOR]  
\*\*[COLOR=#0000FF]EHSS  
[/COLOR]\*\*\*\*[COLOR=#0000FF]Contacts  
[/COLOR]\*\*When I click on **[COLOR=#0000FF][/COLOR][COLOR=#FF0000]EHSS[/COLOR]**, it should expand like the following:  
[COLOR=#0000FF] **Home** [/COLOR]  
[COLOR=#0000FF] **Schedule** [/COLOR]  
**[COLOR=#0000FF]EHSS  
[/COLOR]**----[COLOR=#a52a2a]\*\*Environment \*\*[/COLOR]  
----[COLOR=#a52a2a] **Health** [/COLOR]  
----[COLOR=#a52a2a] **Safety** [/COLOR]  
----[COLOR=#a52a2a] **Security** [/COLOR]  
\*\*[COLOR=#0000FF]Contacts

[/COLOR]\*\*How it can be done using AS3. I have made my own buttons of size (200 x 20).  
**[COLOR=#0000FF][/COLOR]**  
Please help me with the as3 code to auto adjust to expand or collapse according to the button clicked.

Thanks.
