AS3 Change textfield inside movieclip added from library

喜欢而已 提交于 2020-01-05 10:19:14

问题


I'm trying to do the following:

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

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";

but I get the error: #1010: One term is not defined and has no properties

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.


回答1:


the MovieClip you instantiate doesn't have an instance name, that's why you can't access it through "getChildByName".

Try this:

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";

Please note, if you're zonaCentral_DescripcionProceso is a MovieClip, you can access the text field without the "getChildByName" method.

Cheers, Rob



来源:https://stackoverflow.com/questions/5588174/as3-change-textfield-inside-movieclip-added-from-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!