A Slot Machine in Flex

28.12.2007

Slot machines fascinate me; For some strange reason both my girlfriend and I can walk into a casino and spend literally hours there playing slot machines for pennies. I consider myself a fairly rational person, but even though I know what the odds are of hitting the jackpot, I still think it’s a great game to play.

And I’m not alone: Slots is the number one game played in casinos around the world. It’s the worst game odds-wise, yet the most played. Go figure.

Lately, we’ve been playing a bit online, because we can’t take our daughter to a casino :) So instead of spending a ton of money online, I decided to write a small slot machine application in Flex - just for fun.

Now all I need is to register a company on Gibraltar and get a casino license and I’m all set to become insanely rich!

Try it out here: http://www.topholt.com/SlotMachine/bin-release/SlotMachine.html

It was fun to implement, because I found out that image filters can be applied directly on a BitmapData instance. I use a BlurFilter to create a blurred version of the block graphics to simulate spinning the reels and the “result” of a spin is drawn on-the-fly. Also, there’s some overlay shadowing as well. All in all pretty cool, because it means no pre-processing of the images in Photoshop.

I haven’t calculated the stats on the slot machine yet, nor have I tuned the reels accordingly. Also, there’s no backend - the entire thing runs as a stand-alone SWF-file. And the graphics are crap.

So perhaps there’s still some way to go before I open my casino…

Edit: Cleaned the code up a bit so View Source is now enabled. Please note that I used Flex Builder 3 beta 3 to build this!