问题描述
我正在尝试执行以下操作:
I'm trying to do the following:
我的舞台上有一个空的MovieClip,名为 zonaCentral_mc 。我使用的函数具有以下代码:
I have an empty movieClip in my stage called zonaCentral_mc. I use a function that has this code:
zonaCentral_DescripcionProceso = new zonaCentral_DescripcionProceso_mc();
zonaCentral_mc.addChild(zonaCentral_DescripcionProceso);
它将MovieClip zonaCentral_DescripcionProceso 从库加载到空的Movieclip zonaCentral_mc 。加载的MC内部有一个动态文本字段,称为 titulo_text 。如何更改该文字?我正在尝试:
It loads the MovieClip zonaCentral_DescripcionProceso from the library into the empty movieclip zonaCentral_mc. The loaded MC has a dynamic textfield called titulo_text inside. How can I change that text? I'm trying:
this["zonaCentral_mc"].getChildByName("zonaCentral_DescripcionProceso").getChildByName("titulo_text").text = "hello";
但出现错误:#1010:一个术语未定义且没有属性
我还尝试了点表示法 this [ zonaCentral_mc]。zonaCentral_DescripcionProceso.titulo_text.text ,结果相同。
I've also tried the dot notation this["zonaCentral_mc"].zonaCentral_DescripcionProceso.titulo_text.text with the same result.
我访问方法有误吗?为什么没有定义,我相信它们都已定义,并且在我调用上述声明的阶段。
Am I accessing it the wrong way? Why isn't it defined, I believe that they're all defined and in the stage when I call the above statement.
推荐答案
您实例化的MovieClip没有实例名称,这就是为什么您无法通过 getChildByName访问它的原因。
the MovieClip you instantiate doesn't have an instance name, that's why you can't access it through "getChildByName".
尝试一下:
zonaCentral_DescripcionProceso.name = "zonaCentralChildClip";
...
this["zonaCentral_mc"].getChildByName("zonaCentralChildClip").titulo_text.text = "hello";
而且,我很确定您也可以访问文本字段:
But also, I am pretty sure you can access the text field as well:
zonaCentral_DescripcionProceso.titulo_text.text = "hello";
请注意,如果您是 zonaCentral_DescripcionProceso
是一个MovieClip,您可以访问文本字段而无需使用 getChildByName方法。
Please note, if you're zonaCentral_DescripcionProceso
is a MovieClip, you can access the text field without the "getChildByName" method.
干杯,
抢劫
这篇关于AS3更改从库添加的动画片段内的文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!