Frage

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

War es hilfreich?

Lösung

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

Andere Tipps

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;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top