# Button variable problem

**URL:** <https://forum.kirupa.com/t/button-variable-problem/288837>\
**Category:** Uncategorized\
**Created:** [May 21, 2009, 3:44pm UTC](https://forum.kirupa.com/t/button-variable-problem/288837 "2009-05-21T15:44:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kate](https://avatars.discourse-cdn.com/v4/letter/k/f04885/32.png) [@kate](https://forum.kirupa.com/u/kate)\
**Post date:** [May 21, 2009, 3:44pm UTC](https://forum.kirupa.com/t/button-variable-problem/288837/1 "2009-05-21T15:44:19Z")

</div>

Hi,

Please could somebody point me in the right direction with this ? Its an image gallery and I want to trace the id of the photo. I can do this fine when the photo is selected, but I also want to be able to click a button and have it trace which photo is selected. When I try it always says 9 which is the last one, no matter which photo I pick.

Thanks very much

```auto
function released()
{
 for(var i=0;i<numOfItems;i++)
 {
  var t:MovieClip = home["item"+i];
  t.xPos = t._x;
  t.yPos = t._y;
  t.theScale = t._xscale;
  if(t != this._parent)
  {
   var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,t._xscale,0,1,true);
  }
  else
  {
   var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,t._xscale,100,1,true);
   theText.htmlText = t.content;
     t.empty.attachMovie("katestext","katestext2",this.getNextHighestDepth());
     trace (t) <<<this works fine
   t.empty.katestext2.modbtn.onRelease=function(){
                trace(t) <<<this always returns photo 9
 }
  
   }
 
  }
 }

```
