Ok, I have many text area components, all with different instance names on my stage. I’m trying to load variables from an external text file, into these text fields when a button is released.
This is the code that I have on frame 1 of my main timeline:
_root.onData = function () {
_root.minPrem1_txt.text = minPrem;
_root.addPrem1_txt.text = addPrem;
}
This is the code that I have on the button that I want to trigger the loadVariablesNum:
on (release) {
_root.list1_mc.gotoAndStop(1);
loadVariablesNum ("[http://www.newyorklife.com/file/other/choice.txt](http://www.newyorklife.com/file/other/choice.txt)", 0)
}
list1_mc is my dropdown menu, where the button resides.
Here are the problems that I’m running into:
-Once the button is selected, the text areas populate with the correct information, so the loadVariablesNum is working when invoked by the button release, so this is at least the one thing working properly.
-However, before I select the button, my text area components are displaying “undefined” I’m guessing that this is b/c the onData is being called before there are any loadVariables?? So I tried to put the onData function on the button, but now the button doesn’t load the variables anymore, it just displays “undefined”.
Here is the code that I tried on the button that displays “undefined” when released:
on (release) {
_root.list1_mc.gotoAndStop(1);
loadVariablesNum ("[http://www.newyorklife.com/file/other/choice.txt](http://www.newyorklife.com/file/other/choice.txt)", 0);
_root.onData = function () {
_root.minPrem1_txt.text = minPrem;
_root.addPrem1_txt.text = addPrem;
Then I tried this on the button, which displays nothing when the button is released, not even “undefined”:
on (release) {
_root.list1_mc.gotoAndStop(1);
_root.loadVariablesNum ("[http://www.newyorklife.com/file/other/choice.txt](http://www.newyorklife.com/file/other/choice.txt)", 0);
_root.onData = function () {
_root.minPrem1_txt.text = minPrem;
_root.addPrem1_txt.text = addPrem;
How can I get this to work?