Skip to main content
October 17, 2007
Answered

how to retreive the name of an initObject if you use AttachMovie? (a.s. 2.0)

  • October 17, 2007
  • 2 replies
  • 266 views
These are maybe some simple lines of codes, but i would like to find out what bal name is
on my stage. As you can see, you can change all properties of the movieclip, but i can't trace
the name of the bal?

Does anyone know how to do this?

This topic has been closed for replies.
Correct answer Rothrock
I just tested this and it worked fine for me – when I did correctly. As soon as I actually looked closely at your code I found the mistake. Remember flash does what you tell it, not what you want!

In your attachMovie you are giving the new instances a _name which is stored in a variable called "ball"+i. But since that is where you are attaching them they aren't getting any name because no such variable could exist. So that is actually the name you have given them. So I suppose "technically" it is also working thin this format.

My guess is that you want to just name them like this:

this.attachMovie("bal","ball"+i,i,Initmovebal);

Also just a pet peeve of mine the function you are caling iisn't really a movebal function, that is handled by the onEnterFrame. Give it a better name, I think attachBal would be much better.

2 replies

RothrockCorrect answer
Inspiring
October 17, 2007
I just tested this and it worked fine for me – when I did correctly. As soon as I actually looked closely at your code I found the mistake. Remember flash does what you tell it, not what you want!

In your attachMovie you are giving the new instances a _name which is stored in a variable called "ball"+i. But since that is where you are attaching them they aren't getting any name because no such variable could exist. So that is actually the name you have given them. So I suppose "technically" it is also working thin this format.

My guess is that you want to just name them like this:

this.attachMovie("bal","ball"+i,i,Initmovebal);

Also just a pet peeve of mine the function you are caling iisn't really a movebal function, that is handled by the onEnterFrame. Give it a better name, I think attachBal would be much better.
October 22, 2007
Thanks Rothrock ! [This] way it worked! ;)

I can sleep again :)

fanglinyong
Inspiring
October 17, 2007
in your code ,this should use a MC ,the mc has what u want !!