• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Jeramey Jones

AS3 Multiple Frame Video Game Problems - Begginer

4 posts in this topic

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]
[color=#FF0000]at TDQuest/getInventory()[/color]
[color=#FF0000]at TDQuest()[/color]

The full document class code is as follows:


[color=#0000FF]package [/color]
[color=#0000FF]{[/color]
[color=#0000FF]import flash.display.MovieClip;[/color]
[color=#0000FF]import flash.display.SimpleButton;[/color]
[color=#0000FF]import flash.display.*;[/color]
[color=#0000FF]import flash.text.*;[/color]
[color=#0000FF]import flash.ui.*;[/color]
[color=#0000FF]import fl.controls.Button;[/color]
[color=#0000FF]import fl.controls.*;[/color]

[color=#0000FF]public class TDQuest extends MovieClip[/color]
[color=#0000FF]{[/color]
[color=#0000FF]public var invBasic,invCannon,invElemental,invGold,invLumber,invStone,invOre,invGems:uint;[/color]
[color=#0000FF]public var intExp:int;[/color]

[color=#0000FF]public function TDQuest()[/color]
[color=#0000FF]{[/color]
[color=#0000FF]getInventory();[/color]
[color=#0000FF]}[/color]

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

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

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.
0

Share this post


Link to post
Share on other sites
the likely issue is that when calling the gotoAndStop method the contents of the frame don't load immediately . There are two solutions that spring to mind. Either add an enter frame event and check the current frame name until it equals "Inventory" then chek the contents of your text fields or add a frame script using the addFrameScript method which you can find out how use with a quick google search. Hope that helps.
0

Share this post


Link to post
Share on other sites
As a side note it's note a great idea to obtain data from your text fields unless they are input fields and the data is user generated. The better approach is to store the numbers for your gold, lumber and stone in code updating your text fields to display this information as it changes. This helps seperate your visual elements further from your code elements.
0

Share this post


Link to post
Share on other sites
Thank you paulstamp, I will try setting up an enterframe function. As for the data, I am trying to pass the information back and forth between the frames and the code. I will let you know how it turns out.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0