Hey guys,
So I created a movieclip and linked it to a class called CustomButton. Inside the movie clip is a text field with name btnText. I then created a few buttons with this code:
var newBtn:CustomButton = new CustomButton();
// set properties of new button
newBtn.x = INIT_X;
newBtn.y = INIT_Y + (INIT_H*i);
newBtn.btnText.text = myText;
this.addChild(newBtn);
So far, so good. Everything works ok and the code sets the text of the new movieclip. Now, I wanted to actually write the CustomButton class and add some properties and eventually do other stuff with it and so I wrote this:
package
{
import flash.display.MovieClip;
public class CustomButton extends MovieClip
{
public var btnText:String;
public var url:String;
public var desc:String;
public function CustomButton()
{
}
}
}
On trying my script again, it gives me this error:
1119: Access of possibly undefined property text through a reference with static type String
the line of code it refers to is:
newBtn.btnText.text = text;
Any clues?