A term is undefined and has no properties
So I'm trying to do a matching game where I match the food dish with the country it originated from. For example pizza, Italy. I also made another game where you have to click on 4 of the ingredients needed to make a pizza. I know that game works but after I tried making the second game, it gives me that error "A term is undefined and has no properties." What am I doing wrong? Here's my code
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;
import flash.events.Event;
public class Game1 extends MovieClip {
var game1 = new Gamenumber1;
var gameover1 = new GameOverGame1;
var nextlevel = new TheNextLevel;
var game2 = new Gamenumber2;
var count:uint;
public function Game1() {
addChild(game1);
game1.tomato.addEventListener(MouseEvent.CLICK,TomatoRight);
game1.cheese.addEventListener(MouseEvent.CLICK,CheeseRight);
game1.flour.addEventListener(MouseEvent.CLICK,FlourRight);
game1.yeast.addEventListener(MouseEvent.CLICK,YeastRight);
game1.lettuce.addEventListener(MouseEvent.CLICK,LettuceWrong);
game1.chicken.addEventListener(MouseEvent.CLICK,ChickenWrong);
game1.beef.addEventListener(MouseEvent.CLICK,BeefWrong);
game1.rice.addEventListener(MouseEvent.CLICK,RiceWrong);
gameover1.startoverbutton.addEventListener(MouseEvent.CLICK,StartOverButton);
nextlevel.nextlevelbutton.addEventListener(MouseEvent.CLICK,NextLevelButton);
game2.USAFlag.addEventListener(MouseEvent.CLICK,USA123);
game2.ChinaFlag.addEventListener(MouseEvent.CLICK,China123);
game2.MexicoFlag.addEventListener(MouseEvent.CLICK,Mexico123);
game2.JapanFlag.addEventListener(MouseEvent.CLICK,Japan123);
game2.GermanyFlag.addEventListener(MouseEvent.CLICK,Germany123);
game2.ItalyFlag.addEventListener(MouseEvent.CLICK,Italy123);
addEventListener(Event.ENTER_FRAME, EnterFrame);
}
function TomatoRight(event:MouseEvent):void {
game1.Correct1.text = "CORRECT!";
count+= 1;
}
function CheeseRight(event:MouseEvent):void {
game1.Correct2.text = "CORRECT!";
count+= 1;
}
function FlourRight(event:MouseEvent):void {
game1.Correct3.text = "CORRECT!";
count+= 1;
}
function YeastRight(event:MouseEvent):void {
game1.Correct4.text = "CORRECT!";
count +=1;
}
function EnterFrame(event:Event):void {
if (count == 4) {
addChild(nextlevel);
removeChild(game1);
}
}
function LettuceWrong(event:MouseEvent):void {
addChild(gameover1);
removeChild(game1);
}
function ChickenWrong(event:MouseEvent):void {
addChild(gameover1);
removeChild(game1);
}
function BeefWrong(event:MouseEvent):void {
addChild(gameover1);
removeChild(game1);
}
function RiceWrong(event:MouseEvent):void {
addChild(gameover1);
removeChild(game1);
}
function StartOverButton(event:MouseEvent):void {
addChild(game1);
removeChild(gameover1);
}//End of game #1
function NextLevelButton(event:MouseEvent):void {
addChild(game2);
removeChild(nextlevel);
}
function USA123(event:MouseEvent):void {
game2.USA.text = "USA and?";
}
function China123(event:MouseEvent):void {
game2.China.text = "China and?";
}
function Mexico123(event:MouseEvent):void {
game2.Mexico.text = "Mexico and?";
}
function Japan123(event:MouseEvent):void {
game2.Japan.text = "Japan and?";
}
function Germany123(event:MouseEvent):void {
game2.Germany.text = "Germany and?";
}
function Italy123(event:MouseEvent):void {
game2.Italy.text = "Italy and?";
}
}
}
