Original Post
Hey All,
I am trying to have my Dynamic Text values communicate across several frames and with the document class. I get a consistent error that states my dynamic text fields contain null values, when they contain numeric values at the time of running the code.
The error is as follows:
[color=#FF0000]TypeError: Error #1009: Cannot access a property or method of a null object reference.
[color=#FF0000]at TDQuest/getInventory()
[color=#FF0000]at TDQuest()
The full document class code is as follows:
[color=#0000FF]package
[color=#0000FF]{
[color=#0000FF]import flash.display.MovieClip;
[color=#0000FF]import flash.display.SimpleButton;
[color=#0000FF]import flash.display.*;
[color=#0000FF]import flash.text.*;
[color=#0000FF]import flash.ui.*;
[color=#0000FF]import fl.controls.Button;
[color=#0000FF]import fl.controls.*;
[color=#0000FF]public class TDQuest extends MovieClip
[color=#0000FF]{
[color=#0000FF]public var invBasic,invCannon,invElemental,invGold,invLumber,invStone,invOre,invGems:uint;
[color=#0000FF]public var intExp:int;
[color=#0000FF]public function TDQuest()
[color=#0000FF]{
[color=#0000FF]getInventory();
[color=#0000FF]}
[color=#0000FF]function UpdateButtons()
[color=#0000FF]{
[color=#0000FF]if (currentLabel=="World Map")
[color=#0000FF]{
[color=#0000FF]btnNav1.label="Character Sheet";
[color=#0000FF]btnNav2.label="Inventory";
[color=#0000FF]btnNav3.label="Shop";
[color=#0000FF]btnNav4.label="Upgrades";
[color=#0000FF]btnNav5.label="Crafting";
[color=#0000FF]btnNav6.label="Main Menu";
[color=#0000FF]}
[color=#0000FF]else if (currentLabel=="Character Sheet")
[color=#0000FF]{
[color=#0000FF]btnNav1.label="World Map";
[color=#0000FF]btnNav2.label="Inventory";
[color=#0000FF]btnNav3.label="Shop";
[color=#0000FF]btnNav4.label="Upgrades";
[color=#0000FF]btnNav5.label="Crafting";
[color=#0000FF]btnNav6.label="Main Menu";
[color=#0000FF]}
[color=#0000FF]else if (currentLabel=="Inventory")
[color=#0000FF]{
[color=#0000FF]btnNav1.label="World Map";
[color=#0000FF]btnNav2.label="Character Sheet";
[color=#0000FF]btnNav3.label="Shop";
[color=#0000FF]btnNav4.label="Upgrades";
[color=#0000FF]btnNav5.label="Crafting";
[color=#0000FF]btnNav6.label="Main Menu";
[color=#0000FF]}
[color=#0000FF]else if (currentLabel=="Shop")
[color=#0000FF]{
[color=#0000FF]btnNav1.label="World Map";
[color=#0000FF]btnNav2.label="Character Sheet";
[color=#0000FF]btnNav3.label="Inventory";
[color=#0000FF]btnNav4.label="Upgrades";
[color=#0000FF]btnNav5.label="Crafting";
[color=#0000FF]btnNav6.label="Main Menu";
[color=#0000FF]}
[color=#0000FF]else if (currentLabel=="Upgrades")
[color=#0000FF]{
[color=#0000FF]btnNav1.label="World Map";
[color=#0000FF]btnNav2.label="Character Sheet";
[color=#0000FF]btnNav3.label="Inventory";
[color=#0000FF]btnNav4.label="Shop";
[color=#0000FF]btnNav5.label="Crafting";
[color=#0000FF]btnNav6.label="Main Menu";
[color=#0000FF]}
[color=#0000FF]else if (currentLabel=="Crafting")
[color=#0000FF]{
[color=#0000FF]btnNav1.label="World Map";
[color=#0000FF]btnNav2.label="Character Sheet";
[color=#0000FF]btnNav3.label="Inventory";
[color=#0000FF]btnNav4.label="Shop";
[color=#0000FF]btnNav5.label="Upgrades";
[color=#0000FF]btnNav6.label="Game Screen";
[color=#0000FF]}
[color=#0000FF]}
[color=#0000FF]public function getInventory()
[color=#0000FF]{
[color=#0000FF]gotoAndStop("Inventory");
[color=#0000FF]invBasic=Number(inventoryBasic.text);
[color=#0000FF]invCannon=Number(inventoryCannon.text);
[color=#0000FF]invElemental=Number(inventoryElemental.text);
[color=#0000FF]invGold=Number(inventoryGold.text);
[color=#0000FF]invLumber=Number(inventoryLumber.text);
[color=#0000FF]invStone=Number(inventoryStone.text);
[color=#0000FF]invOre=Number(inventoryOre.text);
[color=#0000FF]invGems=Number(inventoryGems.text);
[color=#0000FF]trace("Basic Towers: " + invBasic);
[color=#0000FF]trace("Cannon Towers: " + invCannon);
[color=#0000FF]trace("Elemental Towers: " + invElemental);
[color=#0000FF]trace("Gold: " + invGold);
[color=#0000FF]trace("Lumber: " + invLumber);
[color=#0000FF]trace("Stone: " + invStone);
[color=#0000FF]trace("Ore: " + invOre);
[color=#0000FF]trace("Gems: " + invGems);
[color=#0000FF]}
[color=#0000FF]}
[color=#0000FF]}
I have tried moving the code into separate functions, new classes and other document classes. I cannot seem to get the data to transfer to the document class or other frames. I have tried having the document class create and place the text fields with the same result. I am starting to think that there is a configuration setting that I am missing.
Any advice or suggestions would be appreciated.
I am trying to have my Dynamic Text values communicate across several frames and with the document class. I get a consistent error that states my dynamic text fields contain null values, when they contain numeric values at the time of running the code.
The error is as follows:
[color=#FF0000]TypeError: Error #1009: Cannot access a property or method of a null object reference.
[color=#FF0000]at TDQuest/getInventory()
[color=#FF0000]at TDQuest()
The full document class code is as follows:
[color=#0000FF]package
[color=#0000FF]{
[color=#0000FF]import flash.display.MovieClip;
[color=#0000FF]import flash.display.SimpleButton;
[color=#0000FF]import flash.display.*;
[color=#0000FF]import flash.text.*;
[color=#0000FF]import flash.ui.*;
[color=#0000FF]import fl.controls.Button;
[color=#0000FF]import fl.controls.*;
[color=#0000FF]public class TDQuest extends MovieClip
[color=#0000FF]{
[color=#0000FF]public var invBasic,invCannon,invElemental,invGold,invLumber,invStone,invOre,invGems:uint;
[color=#0000FF]public var intExp:int;
[color=#0000FF]public function TDQuest()
[color=#0000FF]{
[color=#0000FF]getInventory();
[color=#0000FF]}
[color=#0000FF]function UpdateButtons()
[color=#0000FF]{
[color=#0000FF]if (currentLabel=="World Map")
[color=#0000FF]{
[color=#0000FF]btnNav1.label="Character Sheet";
[color=#0000FF]btnNav2.label="Inventory";
[color=#0000FF]btnNav3.label="Shop";
[color=#0000FF]btnNav4.label="Upgrades";
[color=#0000FF]btnNav5.label="Crafting";
[color=#0000FF]btnNav6.label="Main Menu";
[color=#0000FF]}
[color=#0000FF]else if (currentLabel=="Character Sheet")
[color=#0000FF]{
[color=#0000FF]btnNav1.label="World Map";
[color=#0000FF]btnNav2.label="Inventory";
[color=#0000FF]btnNav3.label="Shop";
[color=#0000FF]btnNav4.label="Upgrades";
[color=#0000FF]btnNav5.label="Crafting";
[color=#0000FF]btnNav6.label="Main Menu";
[color=#0000FF]}
[color=#0000FF]else if (currentLabel=="Inventory")
[color=#0000FF]{
[color=#0000FF]btnNav1.label="World Map";
[color=#0000FF]btnNav2.label="Character Sheet";
[color=#0000FF]btnNav3.label="Shop";
[color=#0000FF]btnNav4.label="Upgrades";
[color=#0000FF]btnNav5.label="Crafting";
[color=#0000FF]btnNav6.label="Main Menu";
[color=#0000FF]}
[color=#0000FF]else if (currentLabel=="Shop")
[color=#0000FF]{
[color=#0000FF]btnNav1.label="World Map";
[color=#0000FF]btnNav2.label="Character Sheet";
[color=#0000FF]btnNav3.label="Inventory";
[color=#0000FF]btnNav4.label="Upgrades";
[color=#0000FF]btnNav5.label="Crafting";
[color=#0000FF]btnNav6.label="Main Menu";
[color=#0000FF]}
[color=#0000FF]else if (currentLabel=="Upgrades")
[color=#0000FF]{
[color=#0000FF]btnNav1.label="World Map";
[color=#0000FF]btnNav2.label="Character Sheet";
[color=#0000FF]btnNav3.label="Inventory";
[color=#0000FF]btnNav4.label="Shop";
[color=#0000FF]btnNav5.label="Crafting";
[color=#0000FF]btnNav6.label="Main Menu";
[color=#0000FF]}
[color=#0000FF]else if (currentLabel=="Crafting")
[color=#0000FF]{
[color=#0000FF]btnNav1.label="World Map";
[color=#0000FF]btnNav2.label="Character Sheet";
[color=#0000FF]btnNav3.label="Inventory";
[color=#0000FF]btnNav4.label="Shop";
[color=#0000FF]btnNav5.label="Upgrades";
[color=#0000FF]btnNav6.label="Game Screen";
[color=#0000FF]}
[color=#0000FF]}
[color=#0000FF]public function getInventory()
[color=#0000FF]{
[color=#0000FF]gotoAndStop("Inventory");
[color=#0000FF]invBasic=Number(inventoryBasic.text);
[color=#0000FF]invCannon=Number(inventoryCannon.text);
[color=#0000FF]invElemental=Number(inventoryElemental.text);
[color=#0000FF]invGold=Number(inventoryGold.text);
[color=#0000FF]invLumber=Number(inventoryLumber.text);
[color=#0000FF]invStone=Number(inventoryStone.text);
[color=#0000FF]invOre=Number(inventoryOre.text);
[color=#0000FF]invGems=Number(inventoryGems.text);
[color=#0000FF]trace("Basic Towers: " + invBasic);
[color=#0000FF]trace("Cannon Towers: " + invCannon);
[color=#0000FF]trace("Elemental Towers: " + invElemental);
[color=#0000FF]trace("Gold: " + invGold);
[color=#0000FF]trace("Lumber: " + invLumber);
[color=#0000FF]trace("Stone: " + invStone);
[color=#0000FF]trace("Ore: " + invOre);
[color=#0000FF]trace("Gems: " + invGems);
[color=#0000FF]}
[color=#0000FF]}
[color=#0000FF]}
I have tried moving the code into separate functions, new classes and other document classes. I cannot seem to get the data to transfer to the document class or other frames. I have tried having the document class create and place the text fields with the same result. I am starting to think that there is a configuration setting that I am missing.
Any advice or suggestions would be appreciated.