Friday, March 28, 2008

Flex Games programming

I have some experience in flex programming, but only in application development. i love the gui part of flex framework, it is much better than java in my opinion.

This time i try to use flex for game programming, not flash codes compile with flex compiler, but really use flex framework to do game.

The very first problem i encounter was there is no example could be found on net! i wonder why, but nevertheless i still found one close enough example from Rico on Flex, it uses AS3 but purely flash api to create a tetris game. as part of learning i decided to redo this tetris game with flex, that is using concept such as canvas, panel, flexSprite, flexShape and mxml!

Although i just started, i already found 2 useful experience:
1) To create double array, do this will create error
_allBricks[m].push(new Array(MASKS[m].length));
should do this instead
_allBricks[m] = new Array(MASKS[m].length);

2) flexShape don't have to added to flexSprite as child, you can add it directly to canvas. to do that:
var _nextBrickDisplay:Shape = new Shape;
var previewUI:UIComponent = new UIComponent;
previewUI.addChild(_nextBrickDisplay);
this.addChild(previewUI);

No comments: