# Help with script for button

**URL:** https://forum.kirupa.com/t/help-with-script-for-button/262748
**Category:** Uncategorized
**Created:** [June 9, 2008, 5:03pm UTC](https://forum.kirupa.com/t/help-with-script-for-button/262748 "2008-06-09T17:03:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ParanoidAndroid](https://avatars.discourse-cdn.com/v4/letter/p/b19c9b/32.png) [@ParanoidAndroid](https://forum.kirupa.com/u/ParanoidAndroid)
#### Post date: [June 9, 2008, 5:03pm UTC](https://forum.kirupa.com/t/help-with-script-for-button/262748/1 "2008-06-09T17:03:42Z")

</div>

hello everybody.  
i was following a tutorial about some buttons, where the actual button remains pressed until another one is pressed. there’s a

var activeButton:String;

in the main timeline, that keeps the name of the actual button pressed. the button is a clip inside another clip, so i write this in the first frame of the nested clip:

this.onPress=function() {  
//first i change the actual button pressed to the normal state  
\*\* \_parent[\_parent.activeButton].gotoAndStop(“up”);\*\*  
//then change the var to the name of the actual button pressed, this:  
\_parent.\_parent.menuactivo = this.\_name;  
//then leave the actual button pressed:  
this.\_parent.gotoAndStop(“down”);  
};  
but it doesn’t work, the variable doesn’t change and the actual button doesn’t return to the normal state.why??  
besides, the brackets **[]** confuse me, i looked in the flash help and it says that they evaluate an expression and return a value, or access the properties of a movieclip, however i really didn’t understand.  
could anybody help me and tell me why this script doesn’t work, and what those brackets are for?? i’m really confused, i hope somebody can help me, i’d really appreciate it, thanks.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2008, 6:31pm UTC](https://forum.kirupa.com/t/help-with-script-for-button/262748/2 "2008-06-09T18:31:22Z")

</div>

Post .fla.

---

<div class="post-metadata">

### Author: ![ParanoidAndroid](https://avatars.discourse-cdn.com/v4/letter/p/b19c9b/32.png) [@ParanoidAndroid](https://forum.kirupa.com/u/ParanoidAndroid)
#### Post date: [June 10, 2008, 2:14pm UTC](https://forum.kirupa.com/t/help-with-script-for-button/262748/3 "2008-06-10T14:14:47Z")

</div>

sorry here’s the .fla  
as i said, the line with the brackets confuses me []  
can someone explain, please? the buttons don’t work as they should  
thanks

---

<div class="post-metadata">

### Author: ![ParanoidAndroid](https://avatars.discourse-cdn.com/v4/letter/p/b19c9b/32.png) [@ParanoidAndroid](https://forum.kirupa.com/u/ParanoidAndroid)
#### Post date: [June 10, 2008, 9:26pm UTC](https://forum.kirupa.com/t/help-with-script-for-button/262748/4 "2008-06-10T21:26:10Z")

</div>

errr…nobody?  
i was so desperate i started making (irrational,intuitive)tests and guess what: i made it work.  
i changed this line:

\*\* \_parent[\_parent.activeButton].gotoAndStop(“up”);

\*\*for this one

\*\* \_parent.\_parent[\_parent.\_parent.activeButton].gotoAndStop(“up”);

\*\*the problem is I DON’T UNDERSTAND why it does work now. what do these brackets [] do?  
can some mercy soul explain me this???  
please

---

<div class="post-metadata">

### Author: ![ParanoidAndroid](https://avatars.discourse-cdn.com/v4/letter/p/b19c9b/32.png) [@ParanoidAndroid](https://forum.kirupa.com/u/ParanoidAndroid)
#### Post date: [June 13, 2008, 3:16pm UTC](https://forum.kirupa.com/t/help-with-script-for-button/262748/5 "2008-06-13T15:16:11Z")

</div>

…anyone out there? :crying:

---

<div class="post-metadata">

### Author: ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)
#### Post date: [June 13, 2008, 3:33pm UTC](https://forum.kirupa.com/t/help-with-script-for-button/262748/6 "2008-06-13T15:33:54Z")

</div>

_tumbleweed_

I don’t see how hard it would be to make a button remain on a pressed position until another button is pressed

I MAY look into this…

---

<div class="post-metadata">

### Author: ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)
#### Post date: [June 14, 2008, 6:43pm UTC](https://forum.kirupa.com/t/help-with-script-for-button/262748/7 "2008-06-14T18:43:02Z")

</div>

ParanoidAndroid…

You just reached the true scope of the object. [] are used to reference to a clip instance.  
it is a alternative to the eval command.
