# Enable disable onPress and onRollOut button states

**URL:** <https://forum.kirupa.com/t/enable-disable-onpress-and-onrollout-button-states/195204>\
**Category:** Uncategorized\
**Created:** [July 29, 2006, 4:35pm UTC](https://forum.kirupa.com/t/enable-disable-onpress-and-onrollout-button-states/195204 "2006-07-29T16:35:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![davedark](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@davedark](https://forum.kirupa.com/u/davedark)\
**Post date:** [July 29, 2006, 4:35pm UTC](https://forum.kirupa.com/t/enable-disable-onpress-and-onrollout-button-states/195204/1 "2006-07-29T16:35:49Z")

</div>

Hello everyone,

I’m having some trouble getting this code to work. I have two ‘doors’ that open when pressed and close when you rollout. The problem is that I need to disable the onRollOut if the button has been pressed. Otherwise when you rollover continuously it keeps trying to close the ‘doors’. Likewise when you press the doors they keep opening.

I’ve used an invisible button to activate the doors called screen\_1 in the code below.  
Hope someone can help as I new to this and it’s beginning to bug me!

Cheers

```
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]Tween[/COLOR];

```

[COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]easing[/COLOR]._;  
[COLOR=#808080]_// get start end / position of doors for tweening\*[/COLOR]  
[COLOR=#000000] **var** [/COLOR] xpos\_l:[COLOR=#0000FF]Number[/COLOR] = door\_l.[COLOR=#0000FF]\_x[/COLOR];  
[COLOR=#000000] **var** [/COLOR] xpos\_r:[COLOR=#0000FF]Number[/COLOR] = door\_r.[COLOR=#0000FF]\_x[/COLOR];  
[COLOR=#000000] **var** [/COLOR] xpos\_l\_end:[COLOR=#0000FF]Number[/COLOR] = COLOR=#000000[/COLOR];  
[COLOR=#000000] **var** [/COLOR] xpos\_r\_end:[COLOR=#0000FF]Number[/COLOR] = COLOR=#000000[/COLOR];

[COLOR=#808080]_// open doors when button pressed_[/COLOR]  
screen\_[COLOR=#000080]1[/COLOR].[COLOR=#0000FF]onPress[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#000000] **new** [/COLOR] Tween[COLOR=#000000]([/COLOR]door\_l, [COLOR=#FF0000]"\_x"[/COLOR], Bounce.[COLOR=#000080]easeOut[/COLOR], xpos\_l, xpos\_l\_end, [COLOR=#000080]1[/COLOR], [COLOR=#000000] **true** [/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#000000] **new** [/COLOR] Tween[COLOR=#000000]([/COLOR]door\_r, [COLOR=#FF0000]“_x"[/COLOR], Bounce.[COLOR=#000080]easeOut[/COLOR], xpos\_r, xpos\_r\_end, [COLOR=#000080]1[/COLOR], [COLOR=#000000] **true** [/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#000000]}[/COLOR];  
[COLOR=#808080]\*// close doors when button rollover \*[/COLOR]  
screen_[COLOR=#000080]1[/COLOR].[COLOR=#0000FF]onRollOver[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#000000] **new** [/COLOR] Tween[COLOR=#000000]([/COLOR]door\_l, [COLOR=#FF0000]”\_x"[/COLOR], Bounce.[COLOR=#000080]easeOut[/COLOR], xpos\_l\_end, xpos\_l, [COLOR=#000080]1[/COLOR].[COLOR=#000080]5[/COLOR], [COLOR=#000000] **true** [/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#000000] **new** [/COLOR] Tween[COLOR=#000000]([/COLOR]door\_r, [COLOR=#FF0000]"\_x"[/COLOR], Bounce.[COLOR=#000080]easeOut[/COLOR], xpos\_r\_end, xpos\_r, [COLOR=#000080]1[/COLOR].[COLOR=#000080]5[/COLOR], [COLOR=#000000] **true** [/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#000000]}[/COLOR];  
[/LEFT]  
[/FONT]
