我怎样才能改变在SimpleButton实例(按钮符号)的动态文本框的文本? [英] how can i change texts in the dynamic textFields in SimpleButton instance (button symbol)?

查看:242
本文介绍了我怎样才能改变在SimpleButton实例(按钮符号)的动态文本框的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个基本的东西,但我无法找到由serching互联网的答案。

this may be a basic thing, but i couldn't find an answer by serching internet.

我创建了一个简单的按钮 - Istance名=btnsample

I have created a simple button - Istance name = "btnsample"

和有两层

层0〜按钮设计,翻转 - 层1动态文本字段 - 实例名称=txtbtnlabel

layer 0- button design with rollovers - layer 1- dynamic text field - instance name = "txtbtnlabel"

btnsample.txtbtnlabel.text =新按钮标签;

btnsample.txtbtnlabel.text = "new button label;

但它给跟随着错误:-119:可能未定义欢迎使用属性txtbtnlabel通过静态类型flash.display使用一个参考访问:SimpleButton的

but it's giving followin error :-119:Access of possible undefined propety txtbtnlabel through a reference with static type flash.display:simpleButton.

如何解决这个问题呢?

推荐答案

我发现这个问题的解决方案,但我不知道阉这是一个完美的方法或没有,但它的正常工作。

I found a solution for this issue, but i don't know wether this is a perfect method or not, but it's working fine.

解决方案: -

创建一个简单的按钮,放置一个动态文本字段,并跳过即时名该字段。您可以通过索引号访问此动态文本。

create a simple button and place a dynamic text field and skip the instant name for this field. you can access this dynamic text by index number.

但如果你有鼠标旁白任何的视觉效果,那么你需要的按钮标签分配给所有这些阶段在AS3。

but if you have any visual effects on mouse overs then you need to assign the button label to all those stages in as3.

code:

//-----mous Up ----
var samplebtn_doc:DisplayObjectContainer = samplebtn.upState as DisplayObjectContainer;
var labelsamplebtn:TextField = samplebtn_doc.getChildAt(1) as TextField;
labelsamplebtn.text = "new button label";


//-----mous Over ----
var samplebtn_over:DisplayObjectContainer = samplebtn.overState as DisplayObjectContainer;
var labelsamplebtn_over:TextField = samplebtn_over.getChildAt(1) as TextField;
labelsamplebtn_over.text = "new button label";



//-----mous Down ----
var samplebtn_down:DisplayObjectContainer = samplebtn.downState as DisplayObjectContainer;
var labelsamplebtn_down:TextField = samplebtn_down.getChildAt(1) as TextField;
labelsamplebtn_down.text = "new button label";

这篇关于我怎样才能改变在SimpleButton实例(按钮符号)的动态文本框的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆