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 1090169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:19:54+00:00 2026-05-16T23:19:54+00:00

Creating a pacman-like game, where a player eats objects. When a MovieClip (box) eats

  • 0

Creating a pacman-like game, where a player eats objects. When a MovieClip (box) eats a circle on the stage, the score in the dynamic text field should go up by 10 points.

Receiving an error:
line: `scoreField.text = ” ” + string(currentScore);

error message: Call to a possibly undefined method string.

 package {
   import flash.display.Sprite;
   import flash.display.MovieClip;
   import flash.events.Event;
   import flash.events.KeyboardEvent;
   import flash.ui.Keyboard;

   public class Move extends MovieClip {

   //var ScoreObjects:Array = new Array(); // creates ScoreObjects array
      var circle:MovieClip;


      private var keyRight:Boolean=false;
      private var keyLeft:Boolean=false;
      private var keyForward:Boolean=false;
      private var keyBackward:Boolean=false;
      private var forwardMove:int=0;
      private var sideMove:int=0;

      private var inertia:int=8; //amount of friction

   //var score_field:String;
   //var point:MovieClip;
   //private var playerScore:int;

   var currentScore:int;


 // Constructor--------------------------------------------------------------------
      public function Move() {
         init();
      }

 // function init -----------------------------------------------------------------
   function init():void {

         //stage.frameRate=60;
    //var score_field:String="";

  /*ScoreObjects[0] = new Circle();
  ScoreObjects[0].amount = 1; // amount of point -- not sure
  ScoreObjects[0].name = "circle";*/
  circle.amount = 10; // each circle is worth 10 points

  //var playerScore:int = 0;
  var currentScore:int = 0;

         stage.addEventListener(Event.ENTER_FRAME, frameloop);
         stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownEvent);
         stage.addEventListener(KeyboardEvent.KEY_UP, keyUpEvent);

    box.addEventListener(Event.ENTER_FRAME, eatCircle);
    wall.addEventListener(Event.ENTER_FRAME, hitWall);



    //stage.addChild(ScoreObjects[0]); // add Score Objects to stage ------------------------------
    //trace(ScoreObjects[0]);

    /*ScoreObjects[0].x = 105;
    ScoreObjects[0].y = 233;*/

      }

 // function eatCircle --------------------------------------------------------------
 function eatCircle(event:Event):void {

  if (box.hitTestObject(circle)) {
    trace ("I ate the circle");
    stage.removeChild(circle);
    var newPoint:int;
    newPoint = circle.amount;
    // point = ScoreObjects[0].amount //store property's value of amount in variable...?
    calcPoints(newPoint);
    //box.deleteEventListener(Event.ENTER_FRAME, eatCircle)
    //calcScore();
    //playerScore++;
   } else {
    trace ("I didn't eat the circle");
   }
 }

 function calcPoints(newPoint:int):void {
  currentScore += newPoint;
  updateDisplayScore(currentScore); 
 }

 function updateDisplayScore(currentScore:int) {
   scoreField.text = " " + String(currentScore);
   var displayText:String="";   
  displayText = scoreField.text; // assigning the message to the field*/
 }



 // function hitWall --------------------------------------------------------------
 function hitWall(event:Event):void {
  if (box.hitTestObject(wall)) {
    box.y+=6;
   } else if (box.hitTestObject(wall2)) {
    box.y-=6;

   } else if (box.hitTestObject(wall3)) { 
    box.x+=6;

   } else if (box.hitTestObject(wall4)) {
    box.x-=6;
      }

 }

 // function keyDownEvent ------------------------------------------------------------
     function keyDownEvent(event:KeyboardEvent):void {
         switch (event.keyCode) {
            case Keyboard.UP:
               keyForward = true;
               keyBackward = false;
               break;

            case Keyboard.DOWN:
               keyBackward = true;
               keyForward = false;
               break;

            case Keyboard.LEFT:
               keyLeft = true;
               keyRight = false;
               break;

            case Keyboard.RIGHT:
               keyRight = true;
               keyLeft = false;
               break;
         }
      }

 // function keyUpEvent ------------------------------------------------------------
     function keyUpEvent(event:KeyboardEvent):void {
         switch (event.keyCode) {

            case Keyboard.UP:
               keyForward = false;
               break;

            case Keyboard.DOWN:
               keyBackward = false;
               break;

            case Keyboard.LEFT:
               keyLeft = false;
               break;

            case Keyboard.RIGHT:
               keyRight = false;
               break;
         }
      }

 // function frameloop ------------------------------------------------------------
     function frameloop(event:Event):void {

         //amount of force
         if (keyForward) {
            forwardMove -=2;
         }
         if (keyBackward) {
            forwardMove += 2;
         }
         if (keyLeft) {
            sideMove -= 2;
         }
         if (keyRight) {
            sideMove += 2;
         }

         forwardMove +=(0-forwardMove)/inertia;
         sideMove +=(0-sideMove)/inertia;

         box.y+=forwardMove;
         box.x+=sideMove;

   //point = e.currentTarget.amount;


      } 

   }// end of class
}// end of 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-16T23:19:55+00:00Added an answer on May 16, 2026 at 11:19 pm
    scoreField.text = " " + string(currentScore);
    

    should be

    scoreField.text = " " + String(currentScore);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a pacman game in javascript to learn the language, and the
I'm creating a game, pacman specifically as part of my coursework and I'm having
I am creating a pacman-style game. I am trying to remove an instance of
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
Creating a simple RPG game, first time using XNA. Trying to get my character
Creating a calculator-like dialog, I noticed that quickly clicking on a button in IE
Creating a Drawable that is completely empty seems like a common need, as a
Creating a C# install package and I'd like on completed install for the Program
Creating MVC3 Razor Helper like Helper.BeginForm() says that it can be done using extension
So I'm building the pacman game in Java to teach myself game programming. I

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.