Skip to main content
Participant
March 9, 2009
Question

Connecting Array and Frames

  • March 9, 2009
  • 3 replies
  • 685 views
I am really starting to hate actionscript 3.0...the problem is in my movie i have a question, where the user needs to write an anwer in the input text field, and if the answer is correct he should go to a new frame, but if it's wrong he is sent again to a different frame!...the code I'm using is below. As I publish the movie, flash shows that everything is fine, everytime you write a wrong answer it takes the user to the frame it supposed to take, but it if you write the 2nd and 3rd correct answer ("two", "three") it also takes to the "back frame", where it should take it to the "next" frame, it works when you write the 1st correct answer thought!....
and it keeps sending me this message:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at project_fla::MainTimeline/answer()
This topic has been closed for replies.

3 replies

Ned Murphy
Legend
March 9, 2009
You're welcome
March 9, 2009
My bad. Correct thought wrongly expressed. I'll work on that.
Ned Murphy
Legend
March 9, 2009
You don't want to be tracing the result, you want to be tracing the inputs. At least one of them is coming up as an undefined value when your problem arises.

And as long as you say the code is correct, okay, but what you show above is not. It is missing a brace.
romulsAuthor
Participant
March 9, 2009
Thanks for the replays!....i figured out the salution after doing the traces!...
the code was correct...when i put a break; after the gotoAndPlay(); it didn't show an error!....the problem was as you said in the sctructure of the code!...just needed to add a new var!
Thanks again!
Ned Murphy
Legend
March 9, 2009
First check your code to make sure that's not a typo as far as having what appears to be a missing brace } in your else conditional.

Then use a trace() to see what value is coming up undefined/null in the answer function, for instance...

trace(users , input_text.text);
romulsAuthor
Participant
March 9, 2009
the code is correct!...have wrote it 4 times on different movies and still comes up the same message!
the thing is, when i replace:
gotoAndPlay ("next");
to
trace("correct");
and
gotoAndPlay("back");
to
trace("incorrect");

and if i write the correct answer in the input text field (one, two, three)....the trace shows a message:
"correct
incorrect
incorrect"
and if i write some random stuff the trace shows up:
"incorrect
incorrect
incorrect

so it actually does the trace, but when i switch the code back to gotoAndPlay(""), it just shows the error
March 9, 2009
Couple of thoughts.
First, the code is incorrect as shown in the message. Auto format will indicate a format error. Simply counting the brace pairs will reveal four open braces but only three closed braces. This is probably just a copying error but if it is not it needs to be corrected. The compiler does not always respond in the same way as auto format. Using both often clears up code but be aware that auto format some times messes with nested parenthesis.

Second, the error indicates that "next" or "back" might be the null objects that are being called by gotoAndPlay IF the syntax error is truly not present. Use trace to identify the objects that gotoAndPlay is actually getting.