PDA

View Full Version : Dynamic text is Jacking up my buttonMode = true


dvlnblk
07-04-2007, 05:40 PM
Okay, today I am making my first ALL AS3 site. I guess I am going to have to get used to coming here everyday to get answers instead of trying to give them...cool feels like the old days. Well, here it goes:

I have a MC that has a rectangle for a background and a dynamic textField on top of it which I set in it's Class. In that Class I also set the buttonMode to true so I get a hand cursor when the user mouses over the button. The problem is that when I mouse over the background I get the hand cursor just fine but I lose it when I mouse over the dynamic text. Anyone ran into this yet?

Thanks, Dvl

Mazoonist
07-04-2007, 06:19 PM
Hey, dvlnblk,

Hadn't run into it yet, but now that you mention it... I just created a similar mc/button in the authoring tool. Put a dynamic textbox in it, set the buttonMode to true, and sure enough, you're right. No hand cursor on the textbox. Changed the dynamic text box to a static one instead, and that brings back the hand cursor.

I know I'm no help... haha. But so far I don't see a way to get a hand cursor while keeping the textbox dynamic.

Flash Gordon
07-04-2007, 06:21 PM
what about not making the dynamic text selectable?


selectable property

selectable:Boolean [read-write]

Language version: ActionScript 3.0
Player version: Flash Player 9


A Boolean value that indicates whether the text field is selectable. The value true indicates that the text is selectable. The selectable property controls whether a text field is selectable, not whether a text field is editable. A dynamic text field can be selectable even if it is not editable. If a dynamic text field is not selectable, the user cannot select its text.

If selectable is set to false, the text in the text field does not respond to selection commands from the mouse or keyboard, and the text cannot be copied with the Copy command. If selectable is set to true, the text in the text field can be selected with the mouse or keyboard, and the text can be copied with the Copy command. You can select text this way even if the text field is a dynamic text field instead of an input text field.


The default value is true.

dvlnblk
07-04-2007, 06:22 PM
haha, well at least I have company! AS3 rocks, I have a logo animation and 8 nav buttons and not one thing on the stage nor any code. If you open the FLA you would swear that it should do absolutely nothing. Also, I just got a review copy of Moock's new AS3 book and it rocks too! Man that dude is a Flash God!

dvlnblk
07-04-2007, 06:22 PM
what about not making the dynamic text selectable?

Tried that already....still no worky

dvlnblk
07-04-2007, 06:31 PM
what about not making the dynamic text selectable?

Tried it in the code as well and still a no go. Good try though. Any other ideas? This one has me stumped.

Flash Gordon
07-04-2007, 06:35 PM
hm....your right :(

have to wait for someone else to come along.


import flash.text.TextField;
import flash.display.Sprite;

var container:Sprite = new Sprite();
container.x = container.y = 200;
addChild(container);

var rect:Sprite = new Sprite();
rect.graphics.lineStyle(2);
rect.graphics.beginFill(0xFFCCFF);
rect.graphics.drawRect(0, 0, 200, 100);
rect.graphics.endFill();
container.addChild(rect);
rect.addEventListener("click", onClick);
rect.buttonMode = true;

var txt:TextField = new TextField();
txt.text = "Hello world";
txt.selectable = false;
txt.x = txt.y = 40;
container.addChild(txt);


function onClick(event:*):void
{
trace("click");
}

dvlnblk
07-04-2007, 06:48 PM
Haha oh well, thanks for the help, it is greatly appreciated. Hopefully someone has run into this and can lend a hand.

Mazoonist
07-04-2007, 06:59 PM
Making a TextFormat object with an "url" property, and then setting the TextFormat object to the TextField will give you a hand cursor of it's own, but then I'm kind of stuck as to what URL it should go to. I can't think of a dummy url to go to that will have no effect. Null and undefined don't go anywhere, but then the hand cursor is gone again. And it would be kind of kludge workaround anyway.

"lend a hand" -- ha ha I get it!

Mazoonist
07-04-2007, 07:26 PM
Forget that last post. That might give you the hand cursor, but would steal away the action of the CLICK or whatever it was you wanted the button/mc to do.

You're gonna hate this solution, but it works: Make an invisible button and put it over the top of your mc. Instead of programming the mc to do something when clicked or whatever, program the invisible button instead. Now your dynamic text box can stay dynamic, and you'll get a hand cursor over the top of the whole thing.

I said you'd hate it because it's mucking around in the authoring tool instead of moving on with classes and OOP, but maybe there's also a way to do it dynamically.

dvlnblk
07-04-2007, 07:49 PM
Haha, your RIGHT!! I DON'T like it!! ROFLOL...there HAS to be some way to do this as textFields in MovieClips that act as buttons are so common. I appreciate the help Maz even if it is something I couldn't bring myself to do ;)

dvlnblk
07-04-2007, 08:29 PM
Well, I guess I will just have to live without a hand cursor until someone figured it out....lol

BTW: Here is my first all AS3 site...it is just a simple Flash front page with HTML subpages but it IS all AS3, no objects or code in the timeline. If anyone is interested in the source I'd be happy to fork it over. Thanks for all the help...Dvl

http://sphilipsinsurance.com/index.html

Mazoonist
07-05-2007, 12:56 AM
Hey, dvlnblk,

After some digging (read:googling) I finally found it. And it was right here on these forums:

http://www.actionscript.org/forums/showthread.php3?t=127240

Set the mouseEnabled property of the TextField to false, and then you will get the hand cursor over the whole clip. Even though in the above thread they don't seem to come to a definitive answer, I just tested it and got a hand cursor. Also I put in a CLICK event handler and it still detected clicks anywhere on the clip. Selectable didn't make any difference, and if selectable is true but mouseEnabled is not, the text is not selectable.

Nice site, btw. ;)

Maz

icktoofay
07-05-2007, 04:15 AM
Just so you know (probably not your fault) it said that I don't have flash player 9, even though I do, so it wouldn't give me the flash content without examining the source of the html and going to Main.swf. So, basically, some users that have flash will still see the no-flash version of the site.

dvlnblk
07-05-2007, 03:23 PM
Hey, dvlnblk,

After some digging (read:googling) I finally found it. And it was right here on these forums:

http://www.actionscript.org/forums/showthread.php3?t=127240

Set the mouseEnabled property of the TextField to false, and then you will get the hand cursor over the whole clip. Even though in the above thread they don't seem to come to a definitive answer, I just tested it and got a hand cursor. Also I put in a CLICK event handler and it still detected clicks anywhere on the clip. Selectable didn't make any difference, and if selectable is true but mouseEnabled is not, the text is not selectable.

Nice site, btw. ;)

Maz

Sweet! Thanks!

dvlnblk
07-05-2007, 03:25 PM
Just so you know (probably not your fault) it said that I don't have flash player 9, even though I do, so it wouldn't give me the flash content without examining the source of the html and going to Main.swf. So, basically, some users that have flash will still see the no-flash version of the site.

Hmm, So what am I doing wrong? What is the fix?

dr_zeus
07-05-2007, 05:18 PM
To stop the mouse from switching away from the hand on the TextField, you need to set mouseChildren = false.

icktoofay
07-05-2007, 07:42 PM
I actually don't know the fix, other than experimenting. I use SWFObject and it never happened for me. And I see you're using AC_FL_RunFlashContent or something like that, so you might try switching to SWFObject for a while. It's easy to configure, too.

Mazoonist
07-05-2007, 08:05 PM
Hats off to Dr. Zeus,

myButtonClip.mouseChildren = false;

....seems a lot easier and more concise than this:

myButtonClip.myText.mouseEnabled = false;

Flash Gordon
07-06-2007, 07:51 AM
Cool thanks guys! I used this in my first project as well.

bbb
09-08-2007, 02:41 AM
I couldn't figure out why my buttonmode movies were flickering. mouseChildren = false was needed. I'm glad I saw this post. Thanks!!!

snoozkewl
05-15-2008, 07:16 PM
"Set the mouseEnabled property of the TextField to false", Thank you all for solving this problem :)