29.11.10

Switching to Classes

Actually, there is another issue that I have to sort out before I switch to using separate class files. And that is the naming conventions for each function.

Take a look at this:


Red.addEventListener(MouseEvent.CLICK, RedJump);

function RedJump(event:MouseEvent):void
{
Green.x -= 60;
}

Blue.addEventListener(MouseEvent.CLICK, BlueJump);

function BlueJump(event:MouseEvent):void
{
Green.x +=60;
}

Yellow.addEventListener(MouseEvent.CLICK, YellowJump);

function YellowJump(event:MouseEvent):void
{
Green.y +=60;
}

Orange.addEventListener(MouseEvent.CLICK, OrangeJump);

function OrangeJump(event:MouseEvent):void
{
Green.y -= 60;
}

The issue that I want to fix now is that each class file is named MoveLeft, MoveRight, MoveUp and MoveDown. When I started out, it seemed ok to simply match up the Left, Right, Up and Down with its respective color, but now I want to fix this because I don't want this problem haunting me forever (I want to get in the habit of fixing these issues early on in the process). 

No comments:

Post a Comment