Copy link to clipboard
Copied
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?";
}
}
}
click file>publish settings>swf and tick "permit debugging". retest.
the line number of the problematic code will be in the error message. if you need more help, indicate which line of code is the problem.
Copy link to clipboard
Copied
click file>publish settings>swf and tick "permit debugging". retest.
the line number of the problematic code will be in the error message. if you need more help, indicate which line of code is the problem.
Copy link to clipboard
Copied
What? I don't see publish settings. It says A term is undefined and has no properties.
at Game1() so I assume that it is somewhere here.
public function Game1() {
addChild(game1);
game1.tomato.addEventListener(MouseEvent.CLICK,TomatoR ight);
game1.cheese.addEventListener(MouseEvent.CLICK,CheeseR ight);
game1.flour.addEventListener(MouseEvent.CLICK,FlourRig ht);
game1.yeast.addEventListener(MouseEvent.CLICK,YeastRig ht);
game1.lettuce.addEventListener(MouseEvent.CLICK,Lettuc eWrong);
game1.chicken.addEventListener(MouseEvent.CLICK,Chicke nWrong);
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,Chin a123);
game2.MexicoFlag.addEventListener(MouseEvent.CLICK,Mex ico123);
game2.JapanFlag.addEventListener(MouseEvent.CLICK,Japa n123);
game2.GermanyFlag.addEventListener(MouseEvent.CLICK,Ge rmany123);
game2.ItalyFlag.addEventListener(MouseEvent.CLICK,Ital y123);
addEventListener(Event.ENTER_FRAME, EnterFrame);
}
Problem is my first game already worked before and now it doesn't. Yes I need more help plz
Copy link to clipboard
Copied
Somewhere inside Game 1 (tomato/cheese/flour/etc) is undefined, you can see the exact line where it is located if you follow kglad's instructions (click file>publish settings>swf and tick "permit debugging". retest.).
After you did that, located the error line and check the object, make sure it's exist.
Copy link to clipboard
Copied
Found the problem. Turns out it was just a stupid capitalization error haha. That debugging thing really helps. Thanks a lot for your help!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now