Memory ala Adobe Flex
I got bored this evening, so I whipped together a quick Memory game in Adobe Flex, more as a means to test some basic things … like extending built-in controls (Image) and building out dynamic displays (the images don’t exist in the MXML) and working with them through the event system (adding/removing them from the effect list). The card ‘flip’ is actually just a simple image.source = newSource (each Card has a ‘front’ and ‘back’ source).
Enjoy: http://projects.zoulcreations.com/games/FlexMemory/
Adobe Flex – Enhanced DateField
Today, I ran into a small issue with the default DateField in Adobe Flex 2.0.1 (which also seemed to be an issue in Flex 3 MS3B2). The issue was simply that I could not manually enter my date into the text field and was forced to select it from the PopUp DateChooser. Normally, this wouldn't be a problem ... but when trying to select a date that is several years in the past or future, makes it quite hard. So, I took it upon myself to whip together this little component to use in my project.
It's still fairly new, but is entirely usable. Some things that are missing are validation and date 'string' formats. Currently, the code requires the date to be entered in 'mm/dd/yyyy' format. Although, it does accept 'mm/dd/yy' (assuming the first two 'yy' values are that of the current year).
So, here's the code ... feel free to use it as you like.
com.zoulcreations.flex.controls.DateField source:
XML:
<?xml version="1.0" encoding="utf-8"?> <![CDATA[ import mx.managers.PopUpManager; import mx.controls.DateChooser; import mx.controls.Alert; [Bindable] public var selectedDate:Date; public var showToday:Boolean = false; [Embed(source="C:/Program Files/Adobe/Flex Builder 3/sdks/2.0.1/frameworks/source/mx/controls/DateChooser.png")] [Bindable] private var chooserIcon:Class; private function onCreation():void { if(showToday) { selectedDate = new Date(); } } private function textChanged(event:Event):void { var dp:Array = ti.text.split('/'); if(dp.length == 3) { try { var m:int = int(dp[0]); var d:int = int(dp[1]); var ys:String = dp[2]; var y:int = 1900; if(ys.length == 4) { y = int(ys); } else if(ys.length == 2) { y = int( (new Date()).fullYear.toString().substr(0,2) + ys); } var dt:Date = new Date(y,m-1,d); selectedDate = dt; } catch(err:Error) { Alert.show(err.message, "Date Format Error"); } } } private function chooserChanged(event:Event):void { selectedDate = dc.selectedDate; //ti.text = formatDate(selectedDate); hideChooser(); } private function formatDate(dt:Date):String { var m:int = dt.month; var d:int = dt.date; var y:int = dt.fullYear; return (m + 1) + '/' + d + '/' + y; } private var dc:DateChooser = null; private function imgClicked(event:Event):void { img.setFocus(); if(dc == null) { showChooser(); } else { hideChooser(); } } private function showChooser():void { if(dc == null) { dc = new DateChooser(); dc.selectedDate = selectedDate; dc.addEventListener("change", chooserChanged); PopUpManager.addPopUp(dc, this, false, null); dc.y = this.y + this.height + 4; dc.x = (this.x + this.width) - dc.width; } } private function hideChooser():void { if(dc != null) { PopUpManager.removePopUp(dc); dc = null; } } ]]>
It’s Math, ala Adobe Flex
For those of you who have seen my simple 'Its Math' application written in Torque Game Builder, here's a remake of it in Adobe Flex. The Adobe Flex version actually contains much more 'logic', but is no where near as 'pretty' looking (not that the TGB version was 'pretty' by any means ... haha).
http://projects.zoulcreations.com/games/ItsMath_Flex/
Space Invaders ala Adobe Flex
Ok, I had a really nice story written up, and then Mambo's Story Editor blew up and refreshed the page for no apparent reason. So I'll keep this one short and simple.
http://projects.zoulcreations.com/games/FlexInvaders/
Above is a link to a Space Invaders clone written in Adobe Flex. There are three components that make up this game, the Ship, Shot and Invader classes. The Ship component is the player ship and has simple 'move left/right' functionality along with 'fire shot'. The Shot component is the fiery bullet that the Ship shoots when you press the Spacebar.
The Invader class is fairly simple at this point, and contains little to no logic. The Invaders are currently stale and do not move around the level. This functionality was not required to accomplish my simple test, which was to see if Flex was a suitable game development environment. So far, I'm thinking that is definitely has the potential to develop simple Flash video games ... not sure about it's ability to get more complex -- along with Flex's ability to load up SWF's 'on the fly' ... you could intermix Flash and Flex stuff to make the game more complex (visually).
So give it a try, and let me know what you think ...


