I have 2 xul files (welcome and main) and 1 javascript file. the js file is declared in both xul files.
In the javascript file i have a 'player' class which at the moment has only getname and setname functions with a name variable. I have instantiated the class at the bottom of the file:
var thePlayer = new CPlayer();What im currently doing in the welcome.xul file is saving the name the player enters by calling the setname function (in the js file):
setName()So it works up to here. playerName holds whatever was entered in the 'playername' box in the calling welcome.xul file.
{
playerName = document.getElementById("playername").value;
}
Now i want the main.xul file to display the players name but it says that it is unreferenced. Im fairly certain this is because i have included the js file in each xul file so each one has its own instance of the CPlayer class..
My question is...is it possible to get both xul files to share 1 instance? or would i have to instantiate the object in the welcome.xul file and pass it around...
Thanks