# onRelease Question

**URL:** https://forum.kirupa.com/t/onrelease-question/185753
**Category:** flash
**Created:** [April 16, 2006, 4:12am UTC](https://forum.kirupa.com/t/onrelease-question/185753 "2006-04-16T04:12:11Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![artistwantab](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@artistwantab](https://forum.kirupa.com/u/artistwantab)
#### Post date: [April 16, 2006, 4:12am UTC](https://forum.kirupa.com/t/onrelease-question/185753/1 "2006-04-16T04:12:11Z")

</div>

if you have some code like this.

```auto
 
for (var i = 0; i < lngth; i++) {
var boxNames = ["yb", "ob", "rb", "bb", "pb", "gb"];...
 
this[boxNames*].onRelease = function () {...

```

I want to target all the MC i didn’t click on. How do I do that?

Thanks

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [April 16, 2006, 5:04am UTC](https://forum.kirupa.com/t/onrelease-question/185753/2 "2006-04-16T05:04:37Z")

</div>

```auto
var boxNames = ["yb", "ob", "rb", "bb", "pb", "gb"];
for (var i = 0; i<boxNames.length; i++) {
	var box = this[boxNames*];
	box.id = i;
	box.onRelease = function() {
		targetBoxes(this.id);
	};
}
function targetBoxes(id) {
	for (var i = 0; i<boxNames.length; i++) {
		var box = this[boxNames*];
		if (i != id) {
			trace(box+" is not targetted");
		} else {
			trace(box+" is targetted");
		}
	}
}

```

scotty(-:

---

<div class="post-metadata">

### Author: ![artistwantab](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@artistwantab](https://forum.kirupa.com/u/artistwantab)
#### Post date: [April 16, 2006, 7:42am UTC](https://forum.kirupa.com/t/onrelease-question/185753/3 "2006-04-16T07:42:49Z")

</div>

Thank you.

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [April 16, 2006, 7:55am UTC](https://forum.kirupa.com/t/onrelease-question/185753/4 "2006-04-16T07:55:07Z")

</div>

no problem =)

---

<div class="post-metadata">

### Author: ![artistwantab](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@artistwantab](https://forum.kirupa.com/u/artistwantab)
#### Post date: [April 16, 2006, 8:32am UTC](https://forum.kirupa.com/t/onrelease-question/185753/5 "2006-04-16T08:32:20Z")

</div>

Still can’t get it?

Here is a test .fla I tried.

```auto
for (var i = 0; i < 2; i++) {
 var menuNames = ["yb", "ob"];
 var boxNames;
 switch (i) {
 case 0 :
  var yb:MovieClip = (this.attachMovie ("yelBox", "yelBox", +i, i));
  boxNames = yb;
  yb._x = 200;
  yb._y = 200;
  break;
 case 1 :
  var ob:Button = (this.attachMovie ("orgBox", "orgBox", +i, i));
  boxNames = ob;
  ob._x = 300;
  ob._y = 200;
  break;
  test (boxNames);
 }
}
//Main Menu
function test () {
 var boxNames = ["yb", "ob"];
 for (var i = 0; i < boxNames.length; i++) {
  var box = this[boxNames*];
  box.id = i;
  box.onRelease = function () {
   targetBoxes (this.id);
  };
 }
 function targetBoxes (id) {
  for (var i = 0; i < boxNames.length; i++) {
   var box = this[boxNames*];
   if (i != id) {
    trace (box + " is not targetted");
   }
   else {
    trace (box + " is targetted");
   }
  }
 }
}

```

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [April 16, 2006, 9:20am UTC](https://forum.kirupa.com/t/onrelease-question/185753/6 "2006-04-16T09:20:08Z")

</div>

I have no idea what you’re after but this works

```auto
var boxNames = ["yb", "ob"];
for (var i = 0; i<2; i++) {
	switch (i) {
	case 0 :
		var yb:MovieClip = this.attachMovie("yelBox", "yb", i);
		yb._x = 200;
		yb._y = 200;
		break;
	case 1 :
		var ob:Button = this.attachMovie("orgBox", "ob", i);
		ob._x = 300;
		ob._y = 200;
		break;
	}
	test();
}
//Main Menu
function test() {
	for (var i = 0; i<boxNames.length; i++) {
		var box = this[boxNames*];
		box.id = i;
		box.onRelease = function() {
			targetBoxes(this.id);
		};
	}
}
function targetBoxes(id) {
	for (var i = 0; i<boxNames.length; i++) {
		var box = this[boxNames*];
		if (i != id) {
			trace(box+" is not targetted");
		} else {
			trace(box+" is targetted");
		}
	}
}

```

scotty(-:

---

<div class="post-metadata">

### Author: ![artistwantab](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@artistwantab](https://forum.kirupa.com/u/artistwantab)
#### Post date: [April 16, 2006, 5:26pm UTC](https://forum.kirupa.com/t/onrelease-question/185753/7 "2006-04-16T17:26:02Z")

</div>

Just learning really. Just trying to figure out how all this works.

Thank you.

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [April 17, 2006, 6:40am UTC](https://forum.kirupa.com/t/onrelease-question/185753/8 "2006-04-17T06:40:05Z")

</div>

:thumb:

---

<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: [April 17, 2006, 7:50am UTC](https://forum.kirupa.com/t/onrelease-question/185753/9 "2006-04-17T07:50:08Z")

</div>

[http://www.n99creations.com/?pID=tutorials&col=Blue&tut=basics\_of\_actionscript\_for\_flash&p=1&l=Flash\_MX\_04](http://www.n99creations.com/?pID=tutorials&col=Blue&tut=basics_of_actionscript_for_flash&p=1&l=Flash_MX_04)

will help 😉
