I have a dynamic textfield with an instance name of hiscoreFirstPlayer
. My goal is be able to access all my instances through array. So therefore, I decided to create an array and try to accessing it:
package {
import flash.display.*;
import flash.events.*;
import flash.ui.*;
private var hiscore:Array = [hiscoreFirstPlayer];
class Game extends MovieClip {
//Return null
trace(hiscore[0]);
//TypeError: Error #1009: Cannot access a property or method of a null object reference.
hiscore[0].text = "1000";
//Return 0
trace(hiscoreFirstPlayer);
//Return 1000
hiscoreFirstPlayer.text = "1000";
trace(hiscoreFirstPlayer);
}
}
So what is the proper way to access my instances via array, without returning a null value. It seems that when I put inside the array, is like I am creating a new object and assigning to the variable, thus resulting a null object.