Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 17th, 2008, 01:27 PM
Frank Grimes's Avatar
Frank Grimes Frank Grimes is offline
Plays with fire
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Outside looking in
Posts: 446 Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 16 h 1 m 17 sec
Reputation Power: 21
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:
1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display: DisplayObject.


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

Reply With Quote
  #2  
Old July 17th, 2008, 02:02 PM
Tann San Tann San is offline
Gotta get to the next screen..
Click here for more information.
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,584 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 5 h 42 m 29 sec
Reputation Power: 534
Facebook MySpace
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 :¬)
__________________
-Tann

-Vote for your favorite ActionScript editor here.

Reply With Quote
  #3  
Old July 17th, 2008, 02:07 PM
Frank Grimes's Avatar
Frank Grimes Frank Grimes is offline
Plays with fire
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Outside looking in
Posts: 446 Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 16 h 1 m 17 sec
Reputation Power: 21
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

Reply With Quote
  #4  
Old July 17th, 2008, 02:21 PM
Frank Grimes's Avatar
Frank Grimes Frank Grimes is offline
Plays with fire
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Outside looking in
Posts: 446 Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 16 h 1 m 17 sec
Reputation Power: 21
I take it back. It's not working. Your first solution produce the same error. The other two give me this:

Quote:
1120: Access of undefined property DisplayObject.


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.

Reply With Quote
  #5  
Old July 17th, 2008, 03:30 PM
Tann San Tann San is offline
Gotta get to the next screen..
Click here for more information.
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,584 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 5 h 42 m 29 sec
Reputation Power: 534
Facebook MySpace
Did you import DisplayObject?

import flash.display.DisplayObject;

I tried to write a condensed explanation about target vs currentTarget but failed, it was either too simplified or came across wrong. These two sources explain it although I'm not sure how clear they are, here and here.

Reply With Quote
  #6  
Old July 17th, 2008, 10:36 PM
Frank Grimes's Avatar
Frank Grimes Frank Grimes is offline
Plays with fire
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Outside looking in
Posts: 446 Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level)Frank Grimes User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 16 h 1 m 17 sec
Reputation Power: 21
Hm...that's probably where I went wrong.

And thanks for the info!

:grimey

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > Which currentTarget?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway