Unfortunatly, no method exits on the TextField class in AS3 as it does not extend the Sprite class, which contains the buttonMode property.
This is most apparent with the annoying problem of having a TextField inside your Sprite/MovieClip you;re trying to use as a button, where even after setting buttonMode = true on the button, rolling over the textfield inside the button will revert the Cursor back to default.
To get round this simply use the mouseChildren = false property on your Sprite/Movieclip button.
i.e.
myTextFieldContainingSprite.buttonMode = true;
myTextFieldContainingSprite.mouseChildren = false;
myTextFieldContainingSprite.addEventListener(MouseEvent.MOUSE_DOWN ...... etc
March 31st, 2009 - 10:29
hey thanks this is awesome!!
April 9th, 2009 - 13:04
Thanks for the tip. Worked like a charm and cured some headaches
Cheers
April 21st, 2009 - 19:21
Thanks you just saved my day!
April 24th, 2009 - 09:48
You saved my day, thanks
April 25th, 2009 - 17:41
god bless you brother!
May 11th, 2009 - 22:33
Most useful! Thank you!
May 19th, 2009 - 18:21
Doesn’t the following shorter thing, also work?
myTextField.mouseEnabled=false;
May 29th, 2009 - 00:08
This worked great when “mouseEnabled = false” on my textField did not. Thanks!
You might run into problems if you have the class add both the graphic for the button and the text field. In that case, you have to do some restructuring by having the button class have a subclass that sets “mouseChildren = false” and then creates the textField.
June 12th, 2009 - 16:20
Absolutely wiseful.
Thanks a lot.
July 9th, 2009 - 12:26
Thanks a lot dude
July 13th, 2009 - 13:43
thank you:)
August 4th, 2009 - 12:06
Thanks a lot
August 12th, 2009 - 02:59
Thanksssssss!!!
September 1st, 2009 - 17:05
That’s sweet!
Work like a charm!
thanks!
September 9th, 2009 - 14:59
thanks! this is exactly what i was looking for.
September 15th, 2009 - 13:36
Thanks for this tip. My custom buttons final behave like buttons should.
November 16th, 2009 - 14:15
¡muchas gracias!
January 8th, 2010 - 12:02
Thanks a billion, this belongs in a sticky somewhere.
February 1st, 2010 - 01:26
Thank you so much for this info, it helped me alot. How frustrating it was!!
February 24th, 2010 - 12:09
that was a hard to find tip but it is precious, thank you man
February 24th, 2010 - 23:57
just plain great
February 26th, 2010 - 20:18
Merci beaucoup !
March 18th, 2010 - 11:27
Great, just what I needed!
thnx!
Regards
Eric
March 25th, 2010 - 12:51
You saved my life!!!
April 11th, 2010 - 02:46
“just saved my day” number 4276993775
April 11th, 2010 - 20:00
thanks!
May 1st, 2010 - 06:46
Excelent!!!
Thanks for your help y very cool
June 13th, 2010 - 13:06
This saved my bacon! Thanks
August 6th, 2010 - 23:50
thank you very much!!!
it’s exactly what I was looking for!
September 24th, 2010 - 19:41
Tanks a lot !!!!
Save me hours of search in the Web
October 15th, 2010 - 09:03
Thanks, you saved my day!
November 19th, 2010 - 11:06
Tanks a lot from Brazil! You save the day!
Cheers!
January 18th, 2011 - 11:41
That’s a good one. Thanks
February 1st, 2011 - 14:20
Aweeeeeeeeeesome! Thx
February 21st, 2011 - 20:28
Thanks! quick and effective!
March 3rd, 2011 - 13:53
3Q!
March 17th, 2011 - 15:30
Use Listeners for mouse over and mouse out and switch the cursor with Mouse.cursor = MouseCursor.BUTTON;
It’s simpler!
April 7th, 2011 - 14:11
Thanks Dude! Saved my day too
peace..
May 13th, 2011 - 12:13
I have both
public var mRowNo:TextField = new TextField();
mRowNo.mouseEnabled = false;
mShape.addChild(mRowNo);
mShape.mouseChildren = false;
and my cursor doesnt change but I cant point at the shape properly, the cursor is off, it reacts to the shape next to it. as soon as I take the textfield off it works properly. Any ideas ?
June 6th, 2011 - 10:53
good one..
July 12th, 2011 - 07:20
Thanks for mouseEnabled=false (@ e-builds) and mouseChildren=false.
Simple but useful and makes frustrated
September 1st, 2011 - 13:07
There’s an easier way to do this with the TextFormat class:
var fmt:TextFormat = new TextFormat();
fmt.url = ‘asfunction:’;
var text:TextField = new TextField();
text.defaultTextFormat = fmt;
The only drawback is that the hand is shown only when the cursor’s over the TEXT. So if your TextField’s size is bigger than the actual text in it the hand cursor will not be shown on the part of the TextField with no text.
January 5th, 2012 - 22:49
e-builds: your method works for me! The author’s does not…
It could be because I don’t have an mc with a textfield inside, but I rather have a textfield that I have added to the stage.
Thanks!
January 22nd, 2012 - 21:56
Thanks! helped me allot!!!