title: Undefined Property Error 1120 moving functions?
body: <p>I'm very, VERY new at flash, and I've tried really hard to figure this out but it's not working. I keep getting the same error: "1120 Access of undefined property goGame" on line 96 and "1136 Incorrect number of arguments expected 1" on line 82. </p>
  
  <p>I know both of these errors has something to do with the ordering of my functions, but I find that when I move the functions to be in front of the listener, more errors pop up demanding the same thing, and the only way I can fix those is moving them in front of each other etc. etc. So I'm kind of stuck. Help would be great appreciated! </p>
  
  <pre><code>package 
  {
  
      import flash.display.*;
      import flash.events.*;
      import flash.ui.*;
      import fl.motion.MotionEvent;
      import flash.utils.Timer;
      import flash.utils.*;
  
      public class StartGame extends MovieClip
      {
          var questions: Array=new Array();
          var correctAnswers: Array=new Array("blue","Russia","10","stone","true","hydrogen and oxygen","Rapunzel","magician","The Mona Lisa","string","12","mammal","lightning bolt","lacrosse","do");
          //Creates am array used for the Quiz Time function
          var i = 0;
          //used to track player's movements on board
          var lives = 3;
          //the # of lives given at the beginning of the game
          var collide: Boolean;
          var myTimer: Timer = new Timer(1000, 60);
          //used for timer in Storming the Castle Game
          var count = 0;
          //used to manage chibiKing movements
  
  
  
  
  
  
  
              //stage.addEventListener(Event.ENTER_FRAME,onFrameLoop);
              //loops frames card so animation plays
              //function to get to the master instructions page
  
              //function to get the the main board
  
  
  
          function randomNumber(){
              var number=Math.round(Math.random()*5)+1; 
              return number;
          }//end randomNumber function    
  
  
          function StartGame() 
          {
              instructionsButton.addEventListener(MouseEvent.CLICK, masterInstructions);
              //listener on instructions button to open the instructions page
              goButton.addEventListener(MouseEvent.CLICK, playGame);
              //listener on the first play button to go to the game board
  
  
          }//end StartGame function
          function masterInstructions (event:MouseEvent) {
              gotoAndPlay(2);
              //takes you to the master instructions page
              goButton2.addEventListener(MouseEvent.CLICK, playGame);
              //listener on the first play button to go to the game board
  
          }// end masterInstructions function
  
          function rollDie (event:MouseEvent) {
              goRollButton.removeEventListener (MouseEvent.CLICK, rollDie);
              //makes player unable to click roll button after pressing once
              goRollButton.visible = false;
              //removes visiblity of the roll button one clicked
              goButtonGame.visible = true;
              //makes game button appear so player can proceed to game
              var currentRoll=randomNumber();
              //randomly rolls a number between 1 and 6
              outputNumber.text=String(currentRoll);
              //displays the number rolled 
              var newMoves = i + currentRoll*10;
              //moves player forward, i being the number already moved
              //roll multipled by ten for frame movements of tween
              gameboy.gotoAndStop(newMoves);
              //player stops at the new position
              i = newMoves; 
              //i now changed to rolled number
              if (i&lt;=300) {
                  bossGame();
              }//if player gets to end of board, automatically start boss game
  
          }//end rollDie function
  
          function playGame (event: MouseEvent) {
              gotoAndPlay(3);
              //goes to main board game
              livesOutput.text=String(lives);
              //displays the 3 of lives the player has in the output box
              gameBoard.addEventListener(MouseEvent.CLICK, girlJumps);
              //event listener for a pop up
              goRollButton.addEventListener(MouseEvent.CLICK, rollDie);
              //when pressed, button calls die roll function
              goButtonGame.addEventListener(MouseEvent.CLICK, goGame);
              //when pressed, chooses a random mini game 
              ball.addEventListener(MouseEvent.MOUSE_DOWN,ballStartDrag);
              ball.addEventListener(MouseEvent.MOUSE_UP, ballEndDrag); 
              bear.addEventListener(MouseEvent.MOUSE_DOWN, bearStartDrag);
              bear.addEventListener(MouseEvent.MOUSE_UP, bearEndDrag);
              //functions to create drag and drops for objects on stage game board
              goButtonGame.visible=false;
              //does not display go button so player must roll dice before playing game
  
          }//end playGame function
  
          function ballStartDrag (evt:MouseEvent) {
              ball.startDrag();
  
          }//end ballStartDrag function
  
          function bearStartDrag (evt:MouseEvent) {
              bear.startDrag();
          }//end bearStartDrag function
  
          function ballEndDrag (evt:MouseEvent) {
              ball.stopDrag();
          }//end ballEndDrag function
  
          function bearEndDrag (evt:MouseEvent) {
              bear.stopDrag();
          }//end bearEndDrag function
  
          function girlJumps (evt:MouseEvent) {
              girlJump.gotoAndPlay(2);
              //has character on board to appear by playing tween
          }//end girlJumps function
  
          function bossGame (event:KeyboardEvent) {
  
              stage.addEventListener( KeyboardEvent.KEY_DOWN, finalBoss);
              //listener to player movement when keyboard is pressed
  
              addEventListener(Event.ENTER_FRAME,movefireball);
              //listener to move the fireball
  
              stage.addEventListener(Event.ENTER_FRAME, collision);
              //listener to collisions between symbols on stage
  
              livesBoss.text=String(lives);
              //displays number of lives in text box
  
              fireball.height = 100;
              fireball.width = 100;
              fireball.x=40
              fireball.y=40
              fireball.xVelocity=8;
              fireball.yVelocity=8;
              //sets fireball parameters
  
  
          }//end bossGame function
  
          function movefireball (evt: Event) {
              fireball.x +=fireball.xVelocity;
              fireball.y +=fireball.yVelocity;
              //creates speeds of fireball
              checkfireballtoWall();
              //calls function
  
              var move1:Number=Math.ceil(Math.random()*stage.stageWidth) + 1;
              var move2:Number=Math.ceil(Math.random()*stage.stageWidth) + 1;
              //movements randomly created for king's movements
  
              if (count%100 == 0) {
                  chibiKing.x= move1;
                  chibiKing.y= move2;
                  //reassigns chibiKing's movements
              }
              count++;
              //adds to count after so many seconds
          }//end movefireball function
  
          function checkfireballtoWall(){
              const TOP: Number= 50;
              const BOTTOM: Number= stage.stageHeight;
              const LEFT: Number= 50;
              const RIGHT: Number= stage.stageWidth - 50;
              const REVERSE: int = -1;
              //limits to fireball's movements
  
              if (fireball.y&lt;TOP) {
                  fireball.y=TOP;
                  fireball.yVelocity*=REVERSE;
              }
              else if (fireball.y&gt;BOTTOM) {
                  fireball.y=BOTTOM;
                  fireball.yVelocity*=REVERSE;
              }
              if (fireball.x&lt;LEFT) {
                  fireball.x=LEFT;
                  fireball.xVelocity*=REVERSE;
              }
              else if (fireball.x&gt;RIGHT) {
                  fireball.x=RIGHT;
                  fireball.xVelocity*=REVERSE;
              }
              //reassignes fireball's direction if fireball hits a certain area
          }//end checkfireballtoWall function
  
          function finalBoss (evt: KeyboardEvent) {
              if( evt.keyCode == Keyboard.LEFT )  
                  {player.x = player.x - 6;   
              }
              else if( evt.keyCode == Keyboard.UP )  
                  {player.y = player.y - 6;    
              }
              else if( evt.keyCode == Keyboard.RIGHT )  
                  {player.x = player.x + 6; 
              }
              else if( evt.keyCode == Keyboard.DOWN )  
                  {player.y = player.y + 6;
              }//allows player to move via keyboard control
          }//end finalBoss function
  
          function collision (evt: Event) {
              if (player.hitTestObject(chibiKing)) {
                  gotoAndPlay(14);
                  //if player hits the king, automatically go to win game screen
              if (player.hitTestObject(fireball)) {
                  lives = lives - 1;
                  //if player hits fireball, lose a life
                  if (lives == 0) {
                      gotoAndPlay(11);}
                      //if lives equal to zero, go automatically to lose game screen
                  livesBoss.text=String(lives);
                  //display the lives remaining the text box
                  }
          }//end collision function
  
          function dragonBattle (event:KeyboardEvent) {
                  //inset Dragon Battle code
          }//end dragonBattle function
  
  
  
  
  
  
  
          function goGame (event:MouseEvent) {
              var gameChoose=randomNumber();
              //randomly chooses a game to play from the existing mini games
              if (gameChoose==1 || gameChoose == 2) {
                  gotoAndPlay(4);
                  //game 1 start screen
                  goButton3.addEventListener (MouseEvent.CLICK, stormingTheCastle);
                  //listener to go to Storming the Castle Game
              }//end goGame function
  
              else if (gameChoose==3 &amp;&amp; correctAnswers.length&gt;0) {
                  gotoAndPlay(7)
                  //quiz time start screen
                  quizTimeButton.addEventListener (MouseEvent.CLICK, quizTime);
                  //quiz time start
  
              }
              else {gotoAndPlay(6);
                  //game 2 start screen
                  goButton5.addEventListener (MouseEvent.CLICK, dragonBattle);
                  //listener to start game 2
                  //wizardess.addEventListener (MouseEvent.CLICK, wizardessMagic);}
  
              }
          }//end goGame function
  
          function quizTime (event:MouseEvent) {
  
              questions [0]= "What colour is the sky?";
              questions [1]= "What is the world's biggest country in land mass?";
              questions [2]= "Do Re Mi Fa So La Ti...";
              questions [3]= "How many tentacles does a squid have?";
              questions [4]= "In Greek Mythology, looking into Medusa's eyes would turn you to...?";
              questions [5]= "True or False: Winnipeg has a hockey team.";
              questions [6]= "Water is made out of...?";
              questions [7]= "Which princess is the star of Disney's movie 'Tangled'?";
              questions [8]= "Harry Houdini was famous for being a(n)...?";
              questions [9]= "Leonardo Da Vinci famously painted what?";
              questions [10]= "What type of instrument is a sitar?";
              questions [11]= "How many are in a dozen?";
              questions [12]= "Humans are...?";
              questions [13]= "Harry Potter is famous for having a scar shaped as what on his forehead?";
              questions [14]= "What is the national sport of Canada?";
              //creates questions to go with answers created in startGame function    
  
              questionBox.text=questions[questions.length];
              //displays the question at the end of the array
  
              answerQuizTime.addEventListener(MouseEvent.CLICK, quiz);
              //button to proceed to get quiz marker  
  
  
          }//end quizTime function
  
          function quiz (evt:MouseEvent){
              var userAnswer=String(answerInput.text);
              //saves the user's answer in userAnswer variable
              if (userAnswer==correctAnswers[questions.length]) {
                  questions.pop();
                  //removes question from end of array
                  lives = lives + 1;
                  //adds life to player's total lives
                  gotoAndPlay(9);
                  //goes to minigame win screen
              }
              else {
                  questions.pop();
                  //removes question from end of array
                  lives = lives - 1;
                  //removes life from player's total lives
                  gotoAndPlay(10);
                  //goes to minigame lose screen
              }
          }//end quiz function
  
          // handler function for the Arrow Keys to move Player across the stage
          function movePlayer(evt: KeyboardEvent) {
  
              // if key is right arrow, move Player to the right
              if (evt.keyCode == Keyboard.RIGHT) {
                  Player.x += 20;
  
              // if key is left arrow, move Player to the left
              } else if (evt.keyCode == Keyboard.LEFT) {
                  Player.x -= 20;
              }
          }//end movePlayer function
  
  
  
          function stormingTheCastle (event:MouseEvent) {
              // add a listener for a Frame Event
              stage.addEventListener(Event.ENTER_FRAME, onFrameLoop);
  
              // add the listener for Keyboard events to the stage
              stage.addEventListener(KeyboardEvent.KEY_DOWN, movePlayer);
  
              // create a custom speed property for each knight
              //start timer
              knight1.velocity = 4;
              knight2.velocity = 6;
              knight3.velocity = 3;
              knight4.velocity = 5;
              collide = false;
              myTimer.start();
          }//end stormingTheCastle function
  
  
          // each time frame 1 plays, move each knight
          //continues if no collision and count less than 60
          //return each night to top if it reaches the bottom
          function onFrameLoop(evt: Event) {
              if (collide == false &amp;&amp; myTimer.currentCount &lt; 60) {
                  if (knight1.y &gt; 292.2)
                      {knight1.y = 42.45;}
                  if (knight2.y &gt; 292.2)
                      {knight2.y = 42.45;}
                  if (knight3.y &gt; 292.2)
                      {knight3.y = 42.45;}
                  if (knight4.y &gt; 292.2)
                      {knight4.y = 42.45;}
  
                  //move knights down by its speed property amount
                  knight1.y = knight1.y + knight1.velocity;
                  knight2.y = knight2.y + knight2.velocity;
                  knight3.y = knight3.y + knight3.velocity;
                  knight4.y = knight4.y + knight4.velocity;
  
                  //trace timer count
                  trace(myTimer.currentCount);
  
                  //if Player is hit by a knight collision is true
                  if (knight1.hitTestObject(Player) == true) {
                      collide = true;
                      trace("test");
                  }
                  if (knight2.hitTestObject(Player) == true) {
                      collide = true;
                  }
                  if (knight3.hitTestObject(Player) == true) {
                      collide = true;
                  }
                  if (knight4.hitTestObject(Player) == true) {
                      collide = true;
                  }
                  else {
                  if (lives == 0) {
                      gotoAndPlay(11);}
                  //trace Game Over when collision is true
                  trace("GAME OVER");
  
                  gotoAndPlay(10);
  
                  }
  
          } //end onFrameLoop function
  
  
      }
  
                  }//end startGame function
  
      }//end class function
  
  }//end package
  </code></pre>