views:

29

answers:

2

I have 4 buttons on my canvas named item1, item2, item3 and item4. In the first frame i've written this code(as2):

stop();
for (n = 0; n <= 10; n++)
{
 this["item" + n].onPress = function ()
 {
  trace('lol');
 };
}

When click the one named item1, it doesn't shows lol, which is funny because if i do this:

stop();
for (n = 0; n <= 10; n++)
{
    trace(n);
 this["item" + n].onPress = function ()
 {
  trace('lol');
 };
}

It outputs:

1
2
3
4

Do someone has an answer? Because to me it looks like simply a bug.

A: 

It's a bug alright, but not in AS2. ;) Realistically, the likelihood is that you have an error somewhere. Perhaps, for example, when you set the name for "item1" you accidentally added a space, or something like that? You might try removing item1 from the stage, re-adding it, an typing in the instance name again.

fenomas
A: 

You were right, but it wasn't my fault. Flash had an weird bug, there wasn't any additional spaces on the item1 instance name, seems flash internally wasn't registering the name right. Anyway you were right on this one, thanks a lot :)

pedrozath