Search code examples
flashactionscript-3textstylesheettextfield

Flash: controlling non-actionscript created text boxes with a style sheet


I have a flash project where I need to create a lot of text boxes manually, i.e. by drawing out the text box on the stage.

This is because all the text boxes have different positions and sizes and trying to create the text boxes in a dynamic way, i.e. via XML would require a lot of tedious X and Y positioning.

That being said, is there a way to control multiple text boxes created this way via a stylesheet?

I've only created text boxes via actionscript that I try to control with a style sheet so I'm not sure how to go about approaching this...


Solution

  • Just give each of them an instance name in the properties window, then you can reference them in their parent's ActionScript as if you created them dynamically.

    enter image description here

    EDIT If using classic TextFields set them to either Dynamic or Input, or user TLFTextFields. Once you have instance names set you can just reference them with their instance name in the code: someText1_txt.text = "hey", or to be a little safer (and to get code hints) cast it when accessing a property, TextField(someText1_txt).text = "hey". Since they are already on the stage you do not have to initialize them with new TextField()