|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Which currentTarget?
Hi--
I've got a container holding several overlapping buttons. I want the button under the arrow to come to the front on MOUSE_OVER and then go back to its original position on MOUSE_OUT. I can do this by creating listeners for every button, but that doesn't seem very efficient so I want to try to consolidate the code, but can't figure out how. My code for the listener: Code:
btnColumn.addEventListener(MouseEvent.MOUSE_OVER, bringFront); btnColumn.addEventListener(MouseEvent.MOUSE_OUT, moveBack); and Code:
function bringFront(e:MouseEvent) {
navContainer.setChildIndex(e.currentTarget, navContainer.numChildren - 1);
}
the error I get when I hover a button: Quote:
I'm not sure what the error is telling me. Tracing the e.currentTarget I see [object btnColumn] so I know I'm close. What am I missing? Thanks! :grimey
__________________
“Be ashamed to die until you have won some victory for humanity.” -- Horace Mann "...all men are created equal." -- US Declaration of Indepenence |
|
#2
|
|||
|
|||
|
Heya, you can just use the target property:
navContainer.setChildIndex(e.target, navContainer.numChildren - 1); You might have to cast it although I don't think you'll have to, try it the above way first then if that doesn't work try casting it: navContainer.setChildIndex(e.target as DisplayObject, navContainer.numChildren - 1); or: navContainer.setChildIndex(DisplayObject(e.target), navContainer.numChildren - 1); Whichever floats ya boat :¬) |
|
#3
|
||||
|
||||
|
Thanks, Tann!
Your first method floats my boat best! ![]() Why didn't my method work? What's the difference between e.currentTarget and e.target? :grimey |
|
#4
|
||||
|
||||
|
I take it back. It's not working. Your first solution produce the same error. The other two give me this:
Quote:
Since it's been giving me the "implicit coercion" error, I got to thinking it didn't like the movieClips I was importing from the library at runtime so I convert them to sprites with this: Code:
var top:Sprite = Sprite(e.target); var topPosition:uint = navContainer.numChildren - 1; navContainer.setChildIndex(top, topPosition); It works, but I still don't understand e.target vs e.currentTarget. |
|
#5
|
|||
|
|||
|
|
|
#6
|
||||
|
||||
|
Hm...that's probably where I went wrong.
And thanks for the info! :grimey |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > Which currentTarget? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|