# Setting boolean values within function, so they don't confilct

**URL:** <https://forum.kirupa.com/t/setting-boolean-values-within-function-so-they-dont-confilct/233518>\
**Category:** Uncategorized\
**Created:** [July 24, 2007, 5:09pm UTC](https://forum.kirupa.com/t/setting-boolean-values-within-function-so-they-dont-confilct/233518 "2007-07-24T17:09:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![graylensman](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@graylensman](https://forum.kirupa.com/u/graylensman)\
**Post date:** [July 24, 2007, 5:09pm UTC](https://forum.kirupa.com/t/setting-boolean-values-within-function-so-they-dont-confilct/233518/1 "2007-07-24T17:09:51Z")

</div>

Greetings, all- Here’s what I’m trying to do: I have a number of buttons on stage. When you rollover, a movie clip is attached. If you roll out, it disappears; if you click, it stays. Then you can drag it around. I’m using a boolean for the rollout disappearing trick. I’ve set these up in named functions.

```auto
function attachBar(word) {
    var showIt=false;
    i++;
    _root.createEmptyMovieClip("bh", getNextHighestDepth());
    bh.attachMovie("infobar", iBar, getNextHighestDepth());
    bh[iBar]._x = _xmouse;
    bh[iBar]._y = _ymouse;
    bh[iBar].tField.text = word;
}
function grabIt() {
    showIt=true;
    bh[iBar].onPress = function() {
        bh[iBar].startDrag();
    };
    bh[iBar].onRelease = function() {
        stopDrag();
    };
}
btn1.onRollOver = function() {
    attachBar("Blade Runner");
    //rollOut function
    btn1.onRollOut = function() {
        if (!showIt) {
            bh.removeMovieClip();
        }
    };
    btn1.onRelease = function() {
        grabIt();
    };
};

```

All this works fine for a single button.

When I apply my code to multiple buttons, however, the boolean gets reset with every rollover, and the previously attached mc disappears. I don’t want to have to set multiple boolean variables, although I suppose I could name them with arguements.

Anybody have any idea for a solution? Thanks!
