Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 8 of 8

Thread: error 1010

  1. #1

    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.


    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++;
        theQuestions[currentQuestion].visible=true;
        
        
    }
    I included a zip of the FLA file, so you can see the random issues I get when it runs

    thank you for taking a look

  2. #2
    If 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

  3. #3
    it 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

  4. #4
    OK now it says line 56, Finally a place two start at
    thanks

  5. #5
    Line 56 is this one, correct?
    Code:
    theQuestions[currentQuestion].visible=true;
    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".

    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)
    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;
    If it still doesn't work, let me know and we'll try something else.
    Blog article of the month: Why My One Line 'if' Statements Are Unusual
    Twitter: @IQAndreas
    GitHub: IQAndreas

  6. #6

    stil 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;
        
        }

  7. #7
    If 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

  8. #8
    Does 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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012