Tuesday, January 31, 2012

As3 TLFTextField instance problems: may be a struct, not a class





I made a class that takes TLFTextfield objects on the stage and passes them to a constructor that uses them to setup an instance of my PL_PreLoader class. While testing I found that it looks like TLFTextFields do not work like ordinary display objects in that when I passed their instance name to my constructor they seem to have been passed by value rather than reference. This would explain why there are now DUPLICATE copies of each TLFTextfield sent to my constructor. I will do another simle test to see if this theory holds. I am thinking maybe TLFTextField internally is actually a STRUCT and not a CLASS.

Update: Further testing shows this problem only happens when the text object is
passed to a class that extends Sprite or MovieClip. And my guess, any display object. Also interesting is that this duplication only happens ONCE. Meaning taking the TLFTextField instance on stage and passing it multiple times to constructors of a class that extends sprite... the cloning will only happen once.

No comments:

Post a Comment