Im creating a game in Flash and I have a class that have some text fields that I need to populate in this case a highScore. I get this error.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Meaning that the object doesn´t exist , for some reason.
if (highscore.data.hard != null){
highscore_txt.text= String( highscore.data.hard);.
}
The highscore_txt I have created it , on the design view , meaning timeline.
I have other textfield, that I acess like the score and dont have any problem, this is problable because is acessed and I try to write to the textfield in the constructer of the class. I have done some tests and if I populate the field after all the constructer stuff is done , it works, like when I click some place and call that function using a eventlister.
what can I do , so that only after the class is completed initialized I insert the data in the textfield, is there any event that is listening for the class endes to create itself??
Just put an event Listener in your constructor that listens to the ADDED_TO_STAGE-event 🙂