I need the dynamic created MC to have a standard name, so that I could target its type 开发者_如何转开发(MC / TextField) when its inside a MC holder. But at the same time, I would like it to have a unique name of its on (random numbers) so that I could know which one I should be targeting correctly.
Exp: objectMC.name="object" objectMC.name2="3480945"
At first I was thinking of using name like "object_3480945" with the combination of name and numbers, but then I find it hard to target the object when I just need to use getChildByName to target the type of the object among the others, instead of a specific 1.
Is there anyway to work around this?
flash.utils.getQualifiedClassName() will give you the class name of any given object. You might want to check that out before going further down the route you're going.
That said, since MovieClip
is a dynamic class, you can assign new properties to its objects at runtime as needed.
mc.typeName = 'object';//use the typeName property to get its type.
mc.name = '3480945'; //for getChildByName
You could give your dynamically created MovieClip a single child, also of type MovieClip.
The first will now be an "outer container", and the second, the new one, an "inner container".
Everything else gets added to the inner container.
You can give the outer container one of the names (e.g. "123456"), and the inner container the other ("object").
精彩评论