We have reduced support for legacy browsers.

What does this mean for me? You will always be able to play your favorite games on Kongregate. However, certain site features may suddenly stop working and leave you with a severely degraded experience.

What should I do? We strongly urge all our users to upgrade to modern browsers for a better experience and improved security.

My first game

Hey all, I just finished my first game and as it’s mostly meant to improve my skills I was wondering what the people here think of it. I realize the gameplay isn’t that great.
[http://www.kongregate.com/games/MilkingTheCowMOO/when-cow-moo](http://www.kongregate.com/games/MilkingTheCowMOO/when-cow-moo)
I also have a specific question. In this game I have a lot of repetitive code because every cow requires its own code. As a result I have way too much code that’s nearly identical. How can I prevent this?

I use AS3. I dont really know how to do solve this with a custom class. I’ve used them twice while following a tutorial but I’m not very good at it yet.
Im currently not at home so I cant provide any code but my repetitive code is similar to this:
`
cow1.addEventListener(MouseEvent.CLICK, cow1Listener);
cow2.addEventListener(MouseEvent.CLICK, cow2Listener);
function cow1Listener(MouseEvent):void
{
mcCow1.gotoAndStop("Cut");
}
function cow2Listener(MouseEvent):void
{
mcCow1.gotoAndStop("Cut");
}
`
If you would like to see more I’ll upload my code tomorrow.

You could go something along the lines of:
`
addEventListener(MouseEvent.CLICK, clicked)
function clicked(event:MouseEvent):void{
switch(event.target){
case "mcCow1":
mcCow1.gotoAndStop(weaponType)
break;
case "mcCow2":
mcCow2.gotoAndStop(weaponType)
break;
default:
break;
}
}
}`
You’d have to check what the event target outputs for each of the cows first though, not just use “mcCow1”.
And weaponType would just be the type of weapon you are using, as a String, so that you don’t need to have checks for the weapon type/different event listeners.
You could also go so far as to:
if(event.target is of Class cow) event.target.gotoAndStop(weaponType)
But I don’t know how to do that properly, you’d have to ask someone else.