Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7070793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:36:33+00:00 2026-05-28T05:36:33+00:00

//Handle game logic mcPlayer.update(); //create question mcMathQu.update(); the first update function of external as

  • 0
        //Handle game logic
        mcPlayer.update();
        //create question
        mcMathQu.update(); 

the first “update” function of external as file works , but the instance i added in the 2nd external file, it gives me that error… (there is a 3rd one behind it which works too)

note: the code itself is an external as file of a fla file. (and i checked, everything is linked properly to their individual external as file.

this is the whole function code. (still doing in process.)

        public function update(evt:Event)
    {
        //This is the game loop     


        //Handle user input
        if (right)
        {
            mcPlayer.moveRight();
        }
        else if (left)
        {
            mcPlayer.moveLeft();
        }
        else
        {
            mcPlayer.stopMoving();
        }

        if (jumping && !mcPlayer.isInAir())
        {
            mcPlayer.jump();
        }
        //reset jump
        jumping = false;

        //Handle game logic
        mcPlayer.update();
        //create question
        mcMathQu.update(); 

        for (var i = aliensArray.length - 1; i >= 0; i--)
        {
            aliensArray[i].update();
        }

        //Check for collision between player and platforms
        if (mcPlayer.isFallingDown())
        {
            for (var j = platformsArray.length - 1; j >= 0; j--)
            {
                if (platformsArray[j].hitTestObject(mcPlayer.hitBox))
                {
                    mcPlayer.y = platformsArray[j].y;
                    mcPlayer.hitFloor(platformsArray[j]);

                    //Exit the loops
                    break;
                }
            }
        }

        //Check for collision between player and aliens
        for (var k = aliensArray.length - 1; k >= 0; k--)
        {
            if (aliensArray[k].hitTestObject(mcPlayer.hitBox))
            {
                if (mcPlayer.isFallingDown())
                {
                    //player jumped on it
                    removeChild(aliensArray[k]);
                    aliensArray.splice(k,1);
                }
                else
                {
                    //player is hit
                    gotHit();
                }
            }
        }

        //Check for Game Over
        if (life <= 0)
            gameOver();

        //Handle display
        txtLife.text = String(life);            

        //Check for collision between portals and player
        if (currPortal.hitTestPoint(mcPlayer.x, mcPlayer.y))
        {
            if (currentLabel == "stage1")
                gotoAndStop("stage2");
            else if (currentLabel == "stage2")
            {
                removeEventListener(Event.ENTER_FRAME, update);
                gotoAndStop("win");
            }
        }
    }

and the external as codes

package Game{
//Add in your import statements here
import flash.display.*;
import flash.events.*;
import flash.utils.*;

//...

public class Maths extends MovieClip
{
    //Add in your class variables here
    //private var score:Number;
    private var operand1:Number;
    private var operand2:Number;
    private var mathsign:String;
    private var rdmSign:int;
    private var startNewGame:Boolean; 
    //private var count:Number;
    //private var myTimer:Timer;
    //...
    /* add new var, and put it as random 4 different int, 
    than use it to SET mathsign as + - / x ...  
    dun forget the 60 sec timer. 
    and minus 10 sec if ans wrongly . 
    and 1 min only 30 questions . :D
    note : add in a end game menu + big big score :DDD 
    and a start game one also. 
    */
    public function MathsQuiz()
    {

    }

    public function Maths()
    {


        //score = 0; 
        operand1 = 0;
        operand2 = 0;
        startNewGame = true;
        //count = 60 ; 
        //myTimer = new Timer(1000,count);



        //Get the game loop to execute
        addEventListener(Event.ENTER_FRAME,update);
        stage.addEventListener(KeyboardEvent.KEY_DOWN, checkAnswer);
        //myTimer.addEventListener(TimerEvent.TIMER, ticktock);
        //myTimer.start();  


    }




   // private function ticktock(event:TimerEvent):void 
    //{
   //     txtCountdown.text = String((count)-myTimer.currentCount);
    //}

    private function checkAnswer(evt:KeyboardEvent) 
    {
        if (evt.keyCode == 13)
        {
            if (mathsign == "+" && txtResult.text == String(operand1 + operand2))
            {
                //score += 10;
            }
            else if (mathsign == "-" && txtResult.text == String(operand1 - operand2))
            {
                //score += 10;
            }
            else if (mathsign == "x" && txtResult.text == String(operand1 * operand2))
            {
                //score += 10;
            }
            else if (mathsign == "÷" && txtResult.text == String(operand1 / operand2))
            {
                //score += 10;
            }
            else
            {
                //score -=5;
                //count -=10;
            }
            startNewGame = true;
            txtResult.text = "";
        }

    }

    public function update(evt:Event)
    {

        //die
        //if (txtCountdown.text <= "0")
        //{
            //score = 0;
            //count = 60;
            //startNewGame = true;
        //}
        //random sign is random. 


      if(rdmSign == 1)
      {
           mathsign = "+";
      }
      else if(rdmSign == 2)
      {
           mathsign = "-";
      }
      else if(rdmSign == 3)
      {
           mathsign = "x";
      }
      else if(rdmSign == 4)
      {
           mathsign = "÷";
      }


        //Handle user input


        //Handle game logic
        if (startNewGame == true)
        {
            var max = 12;
            var min = 0;
            operand1 = Math.floor(Math.random()*(max-min+1))+min;
            operand2 = Math.floor(Math.random()*(max-min+1))+min;
            rdmSign = Math.floor(Math.random() *4 + 1);
            startNewGame = false;
        }
        //Handle display
        txtOperand1.text = String(operand1);
        txtOperand2.text = String(operand2);
        txtMathsign.text = String(mathsign);
        //txtScore.text = String(score);
    }       

}//end class    
    }//end package
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:36:33+00:00Added an answer on May 28, 2026 at 5:36 am

    If you’re going to be calling update() without giving it any parameters, just make your first parameter (evt) have a default value of null:

    public function update(evt:Event = null)
    

    Just be careful when updating this method; if you make the use of evt anywhere inside, you’ll have to be sure to wrap in if(evt != null) or similar, eg:

    public function update(evt:Event = null):void
    {
        if(evt != null)
        {
            trace(evt.target);
        }
    }
    

    Otherwise you’re going to get bombarded with some wonderful:

    TypeError: Error #1009: Cannot access a property or method of a null
    object reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a simple card game (human vs. CPU) the logic works, but I want
Because I realized game rule logic should handle huge complexity, I'm considering using of
I am developing 2D game for iPhone, for that I need to handle collision
I recently wrote a Java playing card game and have all the game logic
I'm writing a state manager for a game. I've got most of the logic
So I am trying to create a real simple dice game...more like a dice
I'm a noob database / game dev (actually this will be my first game)
Looking for the proper way to handle orientation in my MonoTouch game (although answers
I am writing a video game in C#, and I would like to handle
How can the shooting game servers handle the timing, for example when a player

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.