Hello!
I created a movie clip symbol with a user interface in it, using the standard components. It contains various components that I draged on the stage. I named the instances (e.g titleLabel).
Then I created an ActionScript class for that user interface. Under the linkage properties of the symbol I specified that class. In the class itself, i declared the attribute “var titleLabel:Label”. I thought this would be the same instance from the symbol? But:
Trying to set the text of the Label AFTER the movie was dynamically added to the parent does not work. I cannot access any properties.
Here is the example:
My Class for the user interface:
import mx.controls.*;
class Information extends MovieClip {
var titleLabel:Label; //this is the same instance name as in the symbol
public function Information() {
trace("information created")
}
function setTitle(title:String) {
trace(this.titleLabel.text) //should print the actual text of the label, but prints undefined
this.titleLabel.text = title;
}
I am loading the “user interface” with the attachMovie function.
After that I am calling the function setTitle on the instance.
var information = this.informationPlaceHolder.attachMovie("information_id", "information", 1);
information.setTitle("Text for the label");
The function “setTitle” gets called properly. But it doesn’t set the text of the label. The property “text” seems undefined. It is like the title label was “null”. But I thought it gets instantiated over the symbol and linkage.
Anyone knows what I am doing wrong here?
Thanks for looking through.
-Iridium77