Tuesday, July 7, 2009

Variable behaviors

While working with public variables within a custom class i had the following observations:

Created a new TextField in the constructor function and change the variable.text in another function by mouseclick. The result was that the textfield was updated at each mouse click.

Conversely if you create the TextField within the mouse click event handler function the textfield keeps placing text on top of text each time the mouse is clicked.

Conclusion, creating TextField by a function variable stacks instance upon instance instead of just changing the single "public variable" each time the mouse is clicked. Might be handy for adding a bunch of graphics on top of one another in the display list.

No comments:

Post a Comment