# Scope headache

**URL:** <https://forum.kirupa.com/t/scope-headache/224453>\
**Category:** Uncategorized\
**Created:** [May 2, 2007, 3:25pm UTC](https://forum.kirupa.com/t/scope-headache/224453 "2007-05-02T15:25:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shellbryson](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@shellbryson](https://forum.kirupa.com/u/shellbryson)\
**Post date:** [May 2, 2007, 3:25pm UTC](https://forum.kirupa.com/t/scope-headache/224453/1 "2007-05-02T15:25:20Z")

</div>

Simple bit of code, a loop that attaches a movie clip, which in turn contains a button. Now, when the button triggers an onRollOver, I need to be able to move the clip which the button resides in. I can’t get it to work, and I think it’s a scope thing;

(where ident\_btn is the instance name of the button in the dynamically attached mc):

```auto

    for (var i=0; i <= 15; i++) {
        identID = "ident" + i;
        var tempgrid = grid_mc.attachMovie("ident_proto", identID, grid_mc.getNextHighestDepth());

        tempgrid.ident_btn.onRollOver = function() {
// MOVE THE CLIP THIS BUTTON BELONGS TO
        }
        
        tempgrid.ident_btn.onRollOut = function() {

// UN MOVE THE CLIP THIS BUTTON BELONGS TO
        }        
        

```

Any suggestions?
