# Combining boolean and button

**URL:** <https://forum.kirupa.com/t/combining-boolean-and-button/278404>\
**Category:** Uncategorized\
**Created:** [December 29, 2008, 3:41pm UTC](https://forum.kirupa.com/t/combining-boolean-and-button/278404 "2008-12-29T15:41:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![masskontroll](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@masskontroll](https://forum.kirupa.com/u/masskontroll)\
**Post date:** [December 29, 2008, 3:41pm UTC](https://forum.kirupa.com/t/combining-boolean-and-button/278404/1 "2008-12-29T15:41:02Z")

</div>

Hi there, I have a piece of actionscript which I would like to have executed when a button is pressed. That same piece of actionscript should execute when a boolean statement is met. Is it possible to combine the two in one script? For instance I now have:

button1.onPress = function (){  
gotoAndPlay (2)  
}

plus:

if (flag1 = true) {  
gotoAndPlay (2);  
}

Can this be made in to a working script like this:

button1.onPress = function () “PLUS” if (flag1 = true) {  
gotoAndPlay (2);  
}

Any help much appeciated. Thanks!
