Forum Topic: AS3 Name Issues..

(90 views • 2 replies)

This topic is 1 page long.

<< < > >>
None

Wurmy

Reply To Post Reply & Quote

Posted at: 10/19/08 01:13 AM

Wurmy LIGHT LEVEL 28

Sign-Up: 06/20/06

Posts: 2,306

Ok, so I'm having some issues with movieclip instance names in AS3.

Here's basically what's going on:

Making a small TD game. The basic turret movieclip is a drawn base, with the part that shoots as it's own movieclip (inside the whole thing). That is named "Top".

Now, all towers are inside one giant movieclip called "Towers". I have a mouse down even listener setup, to select whichever tower. So I tried this:

private function UpdateTowerSelection(e:MouseEvent){
   trace (e.target.name);
}

When I click on the part of the tower movieclip that is just drawn there, I get:

instance##

Which I should get, it's just a name assigned to that moveclip, since I didn't assign any name to it. But, when I click on the shooting part of the turret (which I named "Top" through the Flash IDE), I get the same thing (different numbers).

Eh? I don't know why this is happening. I should get "Top", instead of "instance##". When I stick the "trace(name)" inside the "Top" movieclip, I do get the right thing: "Top"

In the class for the Turret movieclip (parent of the "Top" movieclip) it has plenty of lines with "Top.whatever" and whatnot, and it all works fine. As soon as I change it from "Top" to something else, it gives me an error.

But the "e.target.name" seems to bugged or something, because it actually was working before. I tweaked some things, but that shouldn't have done anything (no hierarchy change)

I have no idea what is going on.. help?
PS: Sorry if I didn't explain well.. I'm not too good at that :(

BBS Signature

None

Moonkey

Reply To Post Reply & Quote

Posted at: 10/19/08 02:08 AM

Moonkey DARK LEVEL 07

Sign-Up: 05/11/07

Posts: 919

Does Top have any children that you might be clicking on instead?


None

Wurmy

Reply To Post Reply & Quote

Posted at: 10/19/08 02:10 AM

Wurmy LIGHT LEVEL 28

Sign-Up: 06/20/06

Posts: 2,306

At 10/19/08 02:08 AM, Moonkey wrote: Does Top have any children that you might be clicking on instead?

Wow, I forgot to check that.. I'm stupid..
Thanks for pointing out the obvious :p

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 06:06 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!