When estente a class from other objects that it contains a MovieClip (MovieClip, TextField, etc ...) they may not be "ready" within the constructor. This happens especially when using more extended MovieClip or components (controls) of Flash. To solve the problem just use the onLoad event inherited from the class itself. For example imagine you have a MovieClip that contains a TextField object (static visual object inside flash) and a TextInput object (inserted control panel components) and want to set some property in the constructor of our class MyClass.
We create a symbol and insert inside either object TextField (let's call text_txt) is the TextInput object (textinput_txt). We associate this symbol to a class that extends MovieClip, call our class MyClass. What we get is that during the constructor of our class MyClass these two controls are initialized. If we try to use a code like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | / / controls . TextInput ; import mx. controls. TextInput; / / MovieClip { class MyClass extends MovieClip { / / text_txt : TextField ; private var text_txt: TextField ; textinput_txt : TextInput ; private var textinput_txt: TextInput; / / function MyClass () { "MiaClasse::costruttore" ) ; trace ("MyClass :: constructor"); / / = "Ciao" ; text_txt. text = "Hello"; = "Ciao" ; textinput_txt. text = "Hello"; / / } } |






Latest Comments
Gabriel : Hello, interesting article. I would need something similar but with some changes. In a ...
sebastian : Great share - thank you!
Subject : very helpful indeed! I tried it and it is just what I needed. Now I wonder how do I get ...
vik : With strategic help!
Pepper : Hi there, I do not know if you're one of the creators of the WP plugin Bannerize. I have spotted a ...