As3 buttons – hand cursor not displaying

4:15 pm on December 17th, 2007, by Jeff Khan

When you add a listener to a movieclip and set it’s buttonMode to true:

buttonname.buttonMode = true;

it should then display the default hand cursor.

But when you have dynamic text inside the movieclip, (even if the text feild is not selectable!) your in for a world of hurt and debugging.

That is unless your set buttonname.mouseChildren = false; which makes the text inside the mc lose focus. It’s set to true by default

Category: Uncategorized 47 comments »

47 Responses to “As3 buttons – hand cursor not displaying”

  1. C4RL05

    Love you. Thanks!

  2. Michelle

    jeff your the best, saved me a lot of stress and work. How did you find out about this!

  3. Jeff

    When you make sites it’s inevitable you’re going to make menu buttons with dynamic titles. It’s just bad luck that value is set to true by default. Just another nuance of AS3 i suppose.

    And who reads though the help files anyway..! :)

  4. Antyler

    Actually I thought it was the contrary so I set mouseChildren = true so as to force the textfield to display the button cursor. After a short while, quick reflex : google + bunch of good keywords and I ended up here. Thanks !

  5. koose

    you my friend are a genius and a godsend. lord knows how long it would have taken to work that out!

    kudos. nice site by the way.

  6. msfx

    just use dynamicTXT.mouseEnabled = false;

    no need for mouseChildren… :) ;)

  7. Paul

    Hey, yea. It probably is a really good hint. Unfortunatelly (unlike the others) I do have problems with it. If I do as you explained, my MouseEvent-Listener does not work anymore. Any Idea?

    thx a lot

    Paul

  8. Paul

    Again me. Found out what my Problem was about. Even if it seems strange … if I add a Listener to the Button Movie Clip, the target of the triggered Event is the textfield inside, and not the movieClip itself. Only if I set button.textfield.mouseEnabled to false or, as you did button.mouseChildren to false the button itself is the target. Does any of you get the sense in that?

  9. Lyndon Fasanya

    This is a first class post you have saved me a world of pain too!

  10. Anon

    Awesome. Thx.

  11. tygershark

    Huge Tip!

  12. Mirko

    Thanks Awesome Tip

  13. Sam Allen

    Paul – you are dead right. To turn a text field in a movie to show a link style hand cursor your have to put somethign like :

    moviesname.textieldname.buttonMode = true;

    Brilliant tips all round – cheers!

  14. Sam Allen

    Sorry – last post update ( You need to also add in mouschildren = false — otherwise the mouse events dont fire properly. )
    mc.buttonMode = true;
    mc.mouseChildren = false;

    For reference check out : http://www.xllusion.net/ed/2007/12/30/as3-buttonmode-issues/ .. implemented in in my code and works a treat

  15. Karel

    I love a first google hit that solves your problem straight away. Thanks!

  16. Paul

    Great tip, I was trying to get this done for almost 30 minutes of googleing around, then finally and luckily found your page. I recently switched from AS2 to AS3 and there are quite some things to learn, but overall it is much more powerful and forces you to write clesn oo code.

    Keep up the good work!

  17. Anees

    Guys,

    If you want to have the hand cursor over a particular textbox inside a movie clip, you can try this..

    textBox.mouseEnabled = false;

    Thanks…

  18. Hunson

    I’m lucky, found you the moment i need you.

    i never would’ve figured it out. AS3 is so stupid, my site is crashing like nobody’s business and I’m going to spend the night fixing it.

  19. matt

    You saved me a lot of trouble – thank you very much!

  20. Kath

    Thank you so much! This saved me so much work!!!

  21. Ion

    lova ya’ ;)

  22. Paul Brassington

    Thanks a million, I’m desiging a product to help millions of children, wonderful tip!

  23. Shane

    Wow!!
    I struggled so hard on this. I created so many work around and could not figure out why the Movie Clip would not register as the event target.

    This is gold. Had to reverse engineer a bunch of stuff but so happy I got it working as I logically think it should.

  24. Cloudwhale

    Thanks so much! This saved a lot of hair pulling.

  25. Andrea

    You saved me, after a year of not using flash, I almost forgot about this.

  26. Jorrit

    GOAAAL!!!!

  27. Felicia

    Thanx. Totally fresh to Actionscript 3.0 but this thread helped me out big time!

  28. Bartonm

    Cheers! Just what I was looking for.

  29. Paul Sheldrake

    Thanks for the tip!

  30. chico

    THANK YOU SO MUCH!!!!!!!!!!!!!!!!!!!!!

  31. bruno

    Thank you very much for saving my time. :)

  32. proxykitten

    Wow, came up first for me in Google when searching for “as3 cursor button.” Thank you!!

  33. upasana

    Thank you very much!

  34. Raphael

    thaaaaankkssssssssss!
    the weir thing is thar I have done that before without the buttonname.mouseChildren = false; and had the same result! Dont know how!

  35. sk2k

    Thanks man! Saved me!

  36. hanna

    Access of possibly undefined property mouseChildren through a reference with static type flash.display:SimpleButton.

    I am getting this error, when i use the
    mc.mouseChildren = false;

    do i need to add anything else too?

  37. DMus

    Saved the Day, Thanks a lot!!!

  38. Ted

    Thanks that solved something I was just working on :)

  39. Santosh

    thank u very much.

  40. Tim Archer

    Great save! Thanks.

  41. Masamune

    Just has to change useHandCursor to buttonMode to display the hand, but thanks ;)

  42. Eduardo Marcolino

    Thank you very much!

  43. Matt

    I’ve got some text inside a button moviec, and the text field is bigger than the parent moviclip. Which means that the hit area for the mouseOver listener is bigger than the button … how do i set it so children text fields and MC’s don’t affect the hit area of the button?

  44. gguk

    thanks. this has bothered me for longggggggggggggggggg.

  45. Andy Mc

    Cheers Jeff, saved me loads of searching :-)

  46. Krio

    Thanks for the tip. You saved my time

  47. Aaron

    Seriously…. you are a gentleman and a scholar. I been spending my days (after work, that is) trawling through tutorials and forums, trying to learn AS3 the <> way. Sure, I’ve found some seriously sweet tutorials in that time…. but this button issue of mine was driving me nuts, and your simple fix was so perfect for what I wanted to do that I just had to drop a ‘thank you’ comment. THANX!!!!!


Leave a Reply



Spam protection by WP Captcha-Free

Back to top