I was hoping I could set up an array of text strings on a main timeline that would be called by the external class script but I get a null object error. I have an interface file (interface.fla) that loads in Game.swf and Game.as class. The timeline of the Game.fla declares an array named “directionsArr”. I then try to reference that array when a button is pressed so that a textfield in the interface.fla (positioned on the stage) displays the text string.
//Script on the Game.fla main timeline
var directionsArr:Array = new Array();
directionsArr[0] = "Select the single best option.";
directionsArr[1] = "Click <b>Submit</b>.";
directionsArr[2] = "Click <b>Continue</b>.";
directionsArr[3] = "Click <b>Results</b> to view your score.";
In Game.as:
package {
public class Game extends MovieClip {
// Interface movieclip that displays user directions
private var directions_mc:MovieClip;
function setDirections(str:String) {
//Textfield in the main interface.fla
directions_mc.directions_tb.htmlText = str;
}
public function pressedBeginButton(event:MouseEvent) {
// Display user directions
setDirections(directionsArr[0]);
}
}
}
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Game/setDirections()
How should I go about this?