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()
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.
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.
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.
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.