Masking textfields at runtime, not embeded(quick fix)

I have a movieclip(instance name:mymc) with some textfields(tf1, tf2, tf3) in it, and that movieclip has a class definition.

The movieclip contains another movieclip(just a simple movieclip with a square shape inside, instance name:masking) with a instance name, and I resize it at runtime. When I set that movieclip as a mask for the for mymc in the class definition, it works, masks all the textfield and shapes.

mask = masking;

however, when i remove that line above and try to mask each object in the movieclip, it only works for movieclips/sprites inside it.

circle.mask = masking;
mc2.mask = masking;
tf1.mask = masking; <---- works
tf2.mask = masking; <---- this line will remove masking on tf1, and then be applied on tf2.
tf3.mask = masking; <---- this will remove on tf2, and then works on tf3.

i know some newbies with as3 like me will be questioning “howcome it doesn’t behave like how the algo is defined?”. my quick fix, put the textfields inside another sprite/mc then apply the mask there.

var s:Sprite = new Sprite();
s.addChild(tf1);
s.addChild(tf2);
s.addChild(tf3);
addChild(s);
s.mask = masking <---- this will now work, masking all of the textfields :slight_smile:

i dunno why this is the behavior with textfields. i hope this quick fix will help you guys :slight_smile: cheers!

any better ways is always welcome :slight_smile: