2010-03-30 113 views
2

我可以更改鼠标光标以使文本字段显示为可点击的对象吗?将textfield()鼠标指针更改为

import flash.display.*; 
import flash.events.*; 
import flash.geom.*; 
import flash.net.*; 
import flash.text.*; 
import flash.ui.ContextMenu; 
import flash.utils.*; 

import mx.core.*; 
+0

你是什么意思?通常,当用户点击文本字段时,您可以使用'onEnter'事件作为文本字段。 – thecoshman 2010-03-30 12:39:39

+0

只想要手出现在那里 – Tom 2010-03-30 12:40:05

回答

2

我假设你希望光标是一个手,这是一个可点击对象的默认值。尝试AS代码如下:

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

或者,在MXML:

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

一个解释见this article

编辑:此代码使用mx.controls.Text对象。如果您希望它与flash.text.TextField对象一起使用,请使用the solution provided by davr

+0

通过引用静态类型flash.text:TextField访问可能未定义的属性buttonMode。 – Tom 2010-03-30 12:45:18

+0

您使用哪种类型的容器包含文本字段? – Prutswonder 2010-03-30 13:12:55

+0

我的课程扩展了Sprite – Tom 2010-03-30 13:33:58

5

您需要将TextField放入Sprite中,将TextField的mouseEnabled设置为false,并将Sprite的buttonMode设置为true。例如:

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); 
+0

对不起,仍然是一个问题,我的整个APP是一个精灵,现在这个精灵根本没有出现? – Tom 2010-04-06 10:00:10

+0

必须是您的代码中的其他错误。如果没有看到整个代码,不能真正提供任何建议。 – davr 2010-04-06 20:22:50