# onPress inside for loops

**URL:** <https://forum.kirupa.com/t/onpress-inside-for-loops/182496>\
**Category:** flash\
**Created:** [March 18, 2006, 9:00pm UTC](https://forum.kirupa.com/t/onpress-inside-for-loops/182496 "2006-03-18T21:00:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cosmicloverocks](https://avatars.discourse-cdn.com/v4/letter/c/dfb087/32.png) [@cosmicloverocks](https://forum.kirupa.com/u/cosmicloverocks)\
**Post date:** [March 18, 2006, 9:00pm UTC](https://forum.kirupa.com/t/onpress-inside-for-loops/182496/1 "2006-03-18T21:00:03Z")

</div>

```auto
function loadSWF(src) {
 _parent.swfContainer.loadMovie(src);
}
my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success) {
 if (success) {
  dir = "thumbs/";
  swfDir = "swf/";
  spacing = 2;
  root = my_xml.firstChild;
  swf = root.firstChild.childNodes;
  thumbs = root.childNodes[1].childNodes;
  for (var i:Number = 0; i<swf.length; i++) {
   container.attachMovie("thumbs", "thumbs"+i, i);
   container["thumbs"+i]._x = i*(66+spacing);
   container["thumbs"+i].loadMovie(dir+thumbs*.firstChild);
   
   this.container["thumbs"+i].onPress=function() {
    //loadSWF(swfDir+swf*.firstChild);
    trace(swf*.firstChild);
   };
   
   trace(swf*.firstChild);
  }
  trace(thumbs.length);;
 } else {
  trace("not laoded");
 }
};
my_xml.load("dustcoverinfo.xml");
MovieClip.prototype.easex = function(x) {
 this.onEnterFrame = function() {
  this._x = x-(x-this._x)/1.200000;
  if (Math.abs(x-this._x)<=1) {
   delete this["onEnterFrame"];
   this._x = x;
  }
  // end if  
 };
};
setRollOver = function () {
 this.onEnterFrame = function() {
  if (this.mask.hitTest(_root._xmouse, _root._ymouse)) {
   slideMenu();
  }
 };
};
slideMenu = function () {
 diff = _root._xmouse-this._x;
 scale = diff*100/this.mask._width;
 target = -scale*(this.container._width-this.mask._width)/100;
 this.arrows.easex(diff);
 this.container.easex(target);
};
setRollOver();

```

the code above … the onPress button dont work dont know why can you guys spot whats wrong thanks …

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [March 18, 2006, 9:47pm UTC](https://forum.kirupa.com/t/onpress-inside-for-loops/182496/2 "2006-03-18T21:47:00Z")

</div>

```auto
this.container["thumbs"+i].onLoad = function(){
this.onPress=function() {
    //loadSWF(swfDir+swf*.firstChild);
    trace(swf*.firstChild);
   };
}

```

---

<div class="post-metadata">

**Author:** ![cosmicloverocks](https://avatars.discourse-cdn.com/v4/letter/c/dfb087/32.png) [@cosmicloverocks](https://forum.kirupa.com/u/cosmicloverocks)\
**Post date:** [March 18, 2006, 10:00pm UTC](https://forum.kirupa.com/t/onpress-inside-for-loops/182496/3 "2006-03-18T22:00:07Z")

</div>

ok thanks ill try it … but i dont understand why does have to use it inside onLoad?

---

<div class="post-metadata">

**Author:** ![cosmicloverocks](https://avatars.discourse-cdn.com/v4/letter/c/dfb087/32.png) [@cosmicloverocks](https://forum.kirupa.com/u/cosmicloverocks)\
**Post date:** [March 18, 2006, 10:01pm UTC](https://forum.kirupa.com/t/onpress-inside-for-loops/182496/4 "2006-03-18T22:01:43Z")

</div>

nope it doesnt work
