View Full Version : getChildIndex()
mattrock23
October 31st, 2007, 02:07 AM
I'm trying to do something based on the index of the object that gets clicked on...
getChildIndex(event.currentTarget)
this doesn't seem to work, the compiler gives an error that I'm trying to implicitly coerce values.
I know this is possible, I've heard people talking about doing this...
mattrock23
October 31st, 2007, 02:17 AM
OK, well If you have ever read a post by me you know this is normal but I just found the answer.
getChildIndex(DisplayObject(event.CurrentTarget)) works.
I guess it's good that it's in the forum now because when I searched before posting this there was nothing...
Felixz
November 1st, 2007, 05:55 AM
Have u tried this
event.target.parent.getChildIndex(event.target);
soulwire
November 1st, 2007, 08:04 AM
I suppose whats happening is, as the event.target object of the event dispatcher is a general object (?), i.e. defined lossely, so in order to use display object methods you first need to cast it back to displayobject or one of its subclasses if you know which the target would be.
pskits
September 23rd, 2011, 06:01 AM
if you named the child could you not put : getChildIndex(event.currentTarget.name);
TheCanadian
September 23rd, 2011, 06:31 AM
I'm sure mattrock appreciates your wrong answer to his 4 year old question which he himself answered correctly 10 minutes after posting it . . . 4 years ago :)
Krilnon
September 23rd, 2011, 11:46 PM
I know I do.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.