if you have some code like this.
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
if you have some code like this.
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
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(-:
Thank you.
no problem =)
Still can’t get it?
Here is a test .fla I tried.
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");
}
}
}
}
I have no idea what you’re after but this works
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(-:
Just learning really. Just trying to figure out how all this works.
Thank you.
:thumb:
:: Copyright KIRUPA 2024 //--