Results 1 to 8 of 8
Thread: error 1010
-
May 2nd, 2012, 01:09 PM #15Registered User
posts
error 1010
I am working on a math game, each image loads up and i have a text box to put the answer in, check answer button, and a message that comes up correct or incorrect. When I go to run it I get the error.
TypeError: Error #1010: A term is undefined and has no properties.
at QuizTwoThree_fla::MainTimeline/checkAnswer()
I have a background in C++, I am not sure if i did not end the loop correctly or what term is not defined. I even went back up to the top and copied and pasted all the variables back over.
I included a zip of the FLA file, so you can see the random issues I get when it runsCode:import flash.events.MouseEvent; import flash.display.MovieClip; import flash.text.TextField; stop(); theEnd.visible=false; var theQuestions:Array = [bob1,bob2,bob3,bob4,bob5,bob6,bob7,bob8,bob9,bob10,bob11,bob12,bob13,bob14,bob15]; var theAnswers:Array = [6.57,7.63,12.44,7.47,7.14,5.39,16.91,3.09,2.03,10.15,15.12,5.27,3.27,2.28,5.55]; var placement:int; var temp:MovieClip; var temp2:int; var currentQuestion:int =0; var score:int = 0; var correct:MovieClip; var inputText:TextField; var scoretwo:int =0; for(var n=0;n<15;n++) { theQuestions[n].visible=false; } for(var i=0; i<15; i++) { placement = (Math.ceil(Math.random()*15)); temp = theQuestions[i]; theQuestions[i] = theQuestions[placement]; theQuestions[placement] = temp; temp2 = theAnswers[i]; theAnswers[i] = theAnswers[placement]; theAnswers[placement] = temp2; } theQuestions[0].visible=true; theButton.addEventListener(MouseEvent.CLICK, checkAnswer); function checkAnswer(e:MouseEvent):void { if(Number(inputText.text)==theAnswers[currentQuestion]) { correct.gotoAndPlay(2); score++; trace(score); } else { scoretwo++; correct.gotoAndPlay(3); trace(scoretwo); } theQuestions[currentQuestion].visible=false; currentQuestion++; theQuestions[currentQuestion].visible=true; }
thank you for taking a look
-
May 2nd, 2012, 01:35 PM #22,703Seņor Member
postsIf you run the SWF by using CTRL+SHIFT+ENTER, Flash will tell you exactly which line the error is at. Which line does it give you?
(and you forgot to include the ZIP file.
It matters not as I'm unable to open FLAs in Linux, so we will try solving this via code only, unless someone else jumps in and can fix it from the FLA)
Blog article of the month: Why My One Line 'if' Statements Are Unusual
Twitter: IQAndreas
GitHub: IQAndreas
-
May 2nd, 2012, 01:44 PM #35Registered User
postsit wont let me upload the zip file for some reason
the error does not give an actual line number it just says
TypeError: Error #1010: A term is undefined and has no properties.
at QuizTwoThree_fla::MainTimeline/checkAnswer()
figuring out why on the file
-
May 2nd, 2012, 01:52 PM #45Registered User
postsOK now it says line 56, Finally a place two start at
thanks
-
May 2nd, 2012, 02:12 PM #52,703Seņor Member
postsLine 56 is this one, correct?
Basically what the error is saying is "You are trying to get or set the property of something that doesn't exist." I'm assuming that the item that doesn't exist is "theQuestions[currentQuestion]", and the property you are trying to access is "visible".Code:theQuestions[currentQuestion].visible=true;
The code looks right, so I'm assuming this is happening when you have answered the last question. In that case, when you bump up "currentQuestion", there is no question after that, so setting the visibility of that non-existent-next-question throws the error.
This should fix it (do whatever you want inside the if statement when the user has answered all questions)
If it still doesn't work, let me know and we'll try something else.Code:theQuestions[currentQuestion].visible=false; currentQuestion++; if (currentQuestion >= theQuestions.length) { //What do you want to do here? //Reset the current question to the very beginning? currentQuestion = 0; //Or perhaps display a dialog saying "You answered all the questions!"? { theQuestions[currentQuestion].visible=true;Blog article of the month: Why My One Line 'if' Statements Are Unusual
Twitter: IQAndreas
GitHub: IQAndreas
-
May 3rd, 2012, 02:52 PM #65Registered User
postsstil crashes
IT seems the error is jumping up now in the code
TypeError: Error #1010: A term is undefined and has no properties.
at QuizTwoThree_fla::MainTimeline/frame1()[QuizTwoThree_fla.MainTimeline::frame1:34]
this is line 34 theQuestions[0].visible=true;
Code:import flash.events.MouseEvent; import flash.display.MovieClip; import flash.text.TextField; stop(); theEnd.visible=false; var theQuestions:Array = [bob1,bob2,bob3,bob4,bob5,bob6,bob7,bob8,bob9,bob10,bob11,bob12,bob13,bob14,bob15]; var theAnswers:Array = [6.57,7.63,12.44,7.47,7.14,5.39,16.91,3.09,2.03,10.15,15.12,5.27,3.27,2.28,5.55]; var placement:int; var temp:MovieClip; var temp2:int; var currentQuestion:int =0; var score:int = 0; var correct:MovieClip; var inputText:TextField; var scoretwo:int =0; for(var n=0;n<15;n++) { theQuestions[n].visible=false; } for(var i=0; i<15; i++) { placement = (Math.ceil(Math.random()*15)); temp = theQuestions[i]; theQuestions[i] = theQuestions[placement]; theQuestions[placement] = temp; temp2 = theAnswers[i]; theAnswers[i] = theAnswers[placement]; theAnswers[placement] = temp2; } theQuestions[0].visible=true; theButton.addEventListener(MouseEvent.CLICK, checkAnswer); function checkAnswer(e:MouseEvent):void { if(Number(inputText.text)==theAnswers[currentQuestion]) { correct.gotoAndPlay(2); score++; trace(score); } else { scoretwo++; correct.gotoAndPlay(3); trace(scoretwo); } theQuestions[currentQuestion].visible=false; currentQuestion++; if (currentQuestion >= theQuestions.length) { trace("HELLO"); } theQuestions[currentQuestion].visible=true; }
-
May 3rd, 2012, 03:05 PM #75Registered User
postsIf i change line 34 to
theQuestions[currentQuestion].visible=true;
the same as the last line of code, the error goes back down to the last line
-
May 4th, 2012, 07:54 AM #82,703Seņor Member
postsDoes it ever trace "hello"? (inside the "if" statement)
Blog article of the month: Why My One Line 'if' Statements Are Unusual
Twitter: IQAndreas
GitHub: IQAndreas

Reply With Quote
Bookmarks