문제

Hi I can go this

var firstname = firstname_mc;
var fname = firstname.getChildAt(0).text;

but

var firstname = MovieClip(firstname_mc).getChildAt(0).text;

does not work

도움이 되었습니까?

해결책

I assume firstname_mc is not a MovieClip instance. Maybe it is an instance of DisplayObjectContainer? Therefore casting fails.

다른 팁

Try this instead :

var firstname = TextField(MovieClip(firstname_mc).getChildAt(0)).text;

Assuming, firstname_mc is a movieclip with a textfield inside that you are trying to access.

If firstname_mc is a movieclip or sprite:

var firstname = TextField(firstname_mc.getChildAt(0)).text;

However, your screwed if you add another movieclip inside the firstname_mc, right under the textfield. Then you are not sure its the child at 0.. So why not give it the textfield a name (like "label_txt")? Then you can do much shorter syntax:

var firstname = firstname_mc.label_txt.text;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top