开发者

Changing cursor for textfield() mouse over

Can I change mouse cursor for textfield to appear as a clickable object?

import flash.display.*;
import flash.e开发者_运维百科vents.*;
import flash.geom.*;
import flash.net.*;
import flash.text.*;
import flash.ui.ContextMenu;
import flash.utils.*;

import mx.core.*;


You need to put the TextField inside a Sprite, sent the TextField's mouseEnabled to false, and the Sprite's buttonMode to true. For example:

var spr:Sprite = new Sprite();
var txt:TextField = new TextField();
txt.text = "Hello World!";
txt.mouseEnabled = false;
spr.buttonMode = true;
spr.addChild(txt);
addChild(spr);


I assume you want the cursor to be a hand, which is a default for clickable objects. Try the following AS code:

myTextField.buttonMode = true;
myTextField.useHandCursor = true;
myTextField.mouseChildren = false;

Or, in MXML:

<mx:Text buttonMode="true" useHandCursor="true" mouseChildren="false" />

See this article for an explanation.

Edit: This code uses the mx.controls.Text object. If you want it to work with flash.text.TextField objects, use the solution provided by davr.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜