Skip to main content
April 8, 2014
Answered

error in action 3

  • April 8, 2014
  • 1 reply
  • 551 views

error in action 3

what this  massage

TypeError: Error #1010: A term is undefined and has no properties.

    at Untitled_fla::MainTimeline/frame1()

the code

import flash.events.MouseEvent;

var questions:Array = new Array();

questions[0] = ["one",1];

questions[1] = ["two",2];

questions[2] = ["three",3];

questions[3] = ["four",4];

questions[4] = ["five",5];

var newArray:Array = new Array();

var randompos:int = 0;

for (var k: int =0; k<questions.length; k++)

{

    randompos = int(math.random() * questions.length);

    while (newArray[randompos] !=null)

    {

        randompos = int(math.random() * questions.length);

    }

    newArray[randompos] = questions;

}

var current:uint = 0;

var scr:uint = 0;

t_text.text = newArray[current][0];

score.text = String(scr) + "/" + String(newArray.length);

pre.text = String(scr) + "%";

right.buttonMode = true;

wrong.buttonMode = true;

right.addEventListener(MouseEvent.CLICK, res);

wrong.addEventListener(MouseEvent.CLICK, res);

function res(e:MouseEvent):void

{

    var id:uint = newArray[current][1];

    switch (e.currentTarget.name)

    {

        case "right":

            if (id==1 || id==2 || id==3)

            {

                scr++;

                score.text = String(scr) + "/" + String(newArray.length);

                pre.text = String(Math.round(scr/ newArray.length*100))+ "%";

                if (current <  newArray.length-1)

                {

                    current++;

                    t_text.text = newArray[current][0];

                }

                else

                {

                    right.removeEventListener(MouseEvent.CLICK, res);

                }

            }

            break;

        case "wrong":

            if (id==4 || id==5)

            {

                scr++;

                score.text = String(scr) + "/" + String(newArray.length);

                pre.text = String(Math.round(scr/ newArray.length*100))+ "%";

                if (current <  newArray.length-1)

                {

                    current++;

                    t_text.text = newArray[current][0];

            }

            else

            {

                wrong.removeEventListener(MouseEvent.CLICK, res);

            }

    }

    break;

}

}

This topic has been closed for replies.
Correct answer Ned Murphy

That indicates that the problem lies on line 26.  If line 26 is....

     t_text.text = newArray[current][0];

then the problem might be that you are treating newArray as if it is a multi-dimensional array when it is not.  Trying changing that to be...

     t_text.text = newArray[current];

If that doesn't fix the error then chances are the issue is with the textfield not being named t_text.

If neither of those is the issue then chances are I missed counting to line 26 and you should help by indicating which one is.

1 reply

Ned Murphy
Legend
April 8, 2014

Go into the Flash Publish Settings and select the option to Permit Debugging.  Doing that will add the line number where the problem lies right after the frame number.

While it could be a number of reasons, it is essentially saying that whatever object you are targeting in the line doesn't exist as far as the code sees it.  You might have missed naming it or misnamed it or something.

April 8, 2014

i,m Carried out these steps shown [test6_fla.MainTimeline::frame1:26]


Ned Murphy
Ned MurphyCorrect answer
Legend
April 8, 2014

That indicates that the problem lies on line 26.  If line 26 is....

     t_text.text = newArray[current][0];

then the problem might be that you are treating newArray as if it is a multi-dimensional array when it is not.  Trying changing that to be...

     t_text.text = newArray[current];

If that doesn't fix the error then chances are the issue is with the textfield not being named t_text.

If neither of those is the issue then chances are I missed counting to line 26 and you should help by indicating which one is.