Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Phlaw

Member Since 13 Apr 2012
Offline Last Active Feb 20 2013 06:17 PM

Topics I've Started

AS3 Multiple Frame Video Game Problems - Begginer

14 April 2012 - 12:42 AM

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:


TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TDQuest/getInventory()
at TDQuest()

The full document class code is as follows:


package
{
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.display.*;
import flash.text.*;
import flash.ui.*;
import fl.controls.Button;
import fl.controls.*;

public class TDQuest extends MovieClip
{
public var invBasic,invCannon,invElemental,invGold,invLumber,invStone,invOre,invGems:uint;
public var intExp:int;

public function TDQuest()
{
getInventory();
}

function UpdateButtons()
{
if (currentLabel=="World Map")
{
btnNav1.label="Character Sheet";
btnNav2.label="Inventory";
btnNav3.label="Shop";
btnNav4.label="Upgrades";
btnNav5.label="Crafting";
btnNav6.label="Main Menu";
}
else if (currentLabel=="Character Sheet")
{
btnNav1.label="World Map";
btnNav2.label="Inventory";
btnNav3.label="Shop";
btnNav4.label="Upgrades";
btnNav5.label="Crafting";
btnNav6.label="Main Menu";
}
else if (currentLabel=="Inventory")
{
btnNav1.label="World Map";
btnNav2.label="Character Sheet";
btnNav3.label="Shop";
btnNav4.label="Upgrades";
btnNav5.label="Crafting";
btnNav6.label="Main Menu";
}
else if (currentLabel=="Shop")
{
btnNav1.label="World Map";
btnNav2.label="Character Sheet";
btnNav3.label="Inventory";
btnNav4.label="Upgrades";
btnNav5.label="Crafting";
btnNav6.label="Main Menu";
}
else if (currentLabel=="Upgrades")
{
btnNav1.label="World Map";
btnNav2.label="Character Sheet";
btnNav3.label="Inventory";
btnNav4.label="Shop";
btnNav5.label="Crafting";
btnNav6.label="Main Menu";
}
else if (currentLabel=="Crafting")
{
btnNav1.label="World Map";
btnNav2.label="Character Sheet";
btnNav3.label="Inventory";
btnNav4.label="Shop";
btnNav5.label="Upgrades";
btnNav6.label="Game Screen";
}
}

public function getInventory()
{
gotoAndStop("Inventory");
invBasic=Number(inventoryBasic.text);
invCannon=Number(inventoryCannon.text);
invElemental=Number(inventoryElemental.text);
invGold=Number(inventoryGold.text);
invLumber=Number(inventoryLumber.text);
invStone=Number(inventoryStone.text);
invOre=Number(inventoryOre.text);
invGems=Number(inventoryGems.text);
trace("Basic Towers: " + invBasic);
trace("Cannon Towers: " + invCannon);
trace("Elemental Towers: " + invElemental);
trace("Gold: " + invGold);
trace("Lumber: " + invLumber);
trace("Stone: " + invStone);
trace("Ore: " + invOre);
trace("Gems: " + invGems);
}
}
}

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.

PARTNERS