SlotFriendzy Game – a Passion Project

In 2012, I had a dream of making a successful slot machine game on Facebook. I spent about 6 months on it during my off-time from work. I even formed a Delaware company to own the game  Рcalled Mookie Games Inc.


The idea of the game was to have a slot machine where the slot items were your friends. It used the Facebook API to grab their profile pictures and basic info about them. You could also launch their profiles from the pictures.
You were given a certain number of coins to begin with, and over time if you ran out, you could purchase more. You could adjust your bet, and the number of pay lines you wanted to bet on. Increasing the pay lines also increased your chances of winning, but increased your wager.
Like real Vegas slot machines, logic was in the game to control your odds of winning, and eventually lead you to making a purchase. I also added lots of free play options such as getting bonuses for each friend of yours that played the game, and how often you and your friends played. Other features such as posting screen captures of your wins, messages on your Facebook wall, and bulk invitations to friends were utilized to make it more viral.

Cloud Deployment

Hoping the game would get used by millions, I decided to learn how deploy cloud based apps using server stacks, virtual machines, load balancers, and distributed databases. I began with Facebook’s default host, Heroku, and then ended up on Amazon Web Services (AWS). I also did research and experimented with others such as App Fog, Google App Engine, and Micorosft Azure.
I picked AWS because of the autoscaling feature. The game was deployed using Git, which would get pushed up to EC2 Virtual Machines behind a load balancer. If the game got heavy usage, more EC2 VMs were automatically launched to handle the load, and then terminated when usage decreased.

Deployment was similar on Heroku, except for the Auto Scaling. I could switch back and forth between Heroku and AWS with the way I had the app set up, using Environment Variables and PHP. I just had to change the url settings on Facebook.


All Flash swfs, images, and sounds were uploaded to an AWS S3 Bucket. I set up an AWS Cloudfront distribution which used that bucket to copy and cache local versions around the world. This was important as I was doing Facebook advertising for my game in several other countries, and I needed the game to have good performance world wide.


Both AWS and Heroku apps were using a cloud Database from a company called Xeround ( no longer in business ). An alternative today could be ClearDB. This is basically a cloud hosted mysql endpoint that has synchronized copies hosted around the world, for better performance. Much of the games features required the use of SQL queries, so I chose MySQL over those no-SQL alternatives.


The server side language for this app was PHP. It used the PHP APIs for Facebook and AWS S3, but most of the PHP was in AMFPHP service classes to handle database operations and communication with Flash. A gambling transaction api was created in the process that had 2 way encryption between the PHP and Flash, and prevented game cheating.

Front End

The Flash App was my largest ActionScript project ever. I proudly architected some clean reusable MVC OOP code that made it easy to invent, integrate, and update features. The graphics assets were from Flash CS6 and published as SWCs, and Flash Develop was the main IDE for coding.

The End

Even though users were making purchases in the game, it never hit a point where it became profitable. Also, a company in the UK claimed the game’s name was too similar to theirs. Facebook never saw a resolution to the dispute and simply shut down the game. All in all, at its peak, the game had over 25,000 users, and was a joy to develop. It allowed thousands of retirees to gamble on the cheap while seeing pictures of their loved ones ūüôā


The Back End – Why Remoting is Better…

The back end for most of my flash portfolio is using AMFPHP Flash Remoting. It’s a free library that came out years ago. I still like it because its performs well and is easy to install-just edit some configs and upload. It’s been a great journey into PHP/mysql as a back end for AS3, and has allowed me to make several RIA’s (Rich Internet Applications) on my own.

For Flash based apps that use a back end, I like Flash Remoting better than JSON, AJAX, REST services, or server side generated xml. I have an opinion on this because I’ve used all of them. Here’s my reasons:

  • Flash sends and¬†receives¬†native Flash objects with any level of¬†hierarchy¬†and complexity. For example, an array of objects containing strings, numbers, and other objects containing arrays of objects. This leads to the next point:
  • No serialization or de-serialization is required, ( the information¬†received¬†is Flash native ). For example, in AS3, you might access your returned data with “[7].areaCode
  • It’s faster because it’s compressed binary, rather than large uncompressed strings
  • It’s faster because it’s socket layer communications, rather than standard http requests

Also, for some speed demo on this, see James Ward’s benchmark.

I know that this particular¬†implementation¬†of Flash Remoting might not suit the needs of a large, enterprise based back end – but there are enterprise level remoting solutions out there. Several flavors are available, not only with PHP, and not all opensource. I’ll post some links of these:

Adobe Live Cycle ( JAVA )

WebORB (.NET, JAVA, PHP, Rails)

Adobe Flash Media Interactive Server

BlazeDS ( JAVA )

Zend AMF ( PHP )


An expanded version of the getDirectory call, but also uses the file name as a key to more information in the database. This is useful for describing media such as video, sound, and pictures. It’s part of my MediaService class in AMFPHP.

To try it out:

  1. go to
  2. Click on MediaService
  3. click on getDirectoryAndFilesInfo
  4. for the dir_ parameter, type in public/vids
  5. click on Submit Query
  6. You should see a list of objects containing information about each video file

This is used in the Video Playlist example.

PHP Source:

  // create an array to hold directory list
  $result = array();
  $directory="../../" . $dir_;
  result = array();
  // create a handler for the directory
  $handler = opendir($directory);
  //do not allow if directory contains ".." SECURITY BREACH!
  $breach = strpos($dir_,"..");
  if ($breach === false  ) {

    // keep going until all files in directory have been read
    while ($file = readdir($handler)) {
      if ($file != '.' && $file != '..')
        $path_parts = pathinfo($file);
        $fObj["size"]= filesize($directory . "/" . $file);
        $fObj["isdir"]=is_dir($directory . "/" . $file);

        if ($fObj["isdir"] || $ext=="flv" || $ext=="jpg" || $ext=="mp3" || $ext=="png")

          $sql2="SELECT COUNT(*) FROM comments WHERE file= '$file'";
          $query2 = mysql_query($sql2);
          $getrow2 =  mysql_fetch_array($query2);

          $sql="SELECT *  FROM filedetails WHERE filename= '" . $file . "'";
          $query = mysql_query($sql);
          $getrow =  mysql_fetch_array($query);
          $fObj["lookup"] = $getrow ;


    // tidy up: close the handler
  return $result;


“getDirectory” is part of my PortfolioService in AMFPHP. It gets the files in a directory and provides info about them such as the name, size, and extension. This information can be read by Flash via Flash Remoting and is¬†received¬†as an array of objects which is binary compressed.

It’s real usefulness is for media viewers (images, sound, video). Once you build a player that uses this service, you can update new songs, videos, etc by simply uploading them to the same folder, and the media is automatically available to the application using the service.

To see live data similar to image above:

  1. go to
  2. Click on PortfolioService
  3. click on getDirectory
  4. for the dir_ parameter, type in mp3
  5. click on Submit Query
  6. You should see a list of objects containing information about each mp3 file

The “mp3” query is used by the MP3 player example.


Launch Flash!see it

  • doodle on pictures using different colors
  • save as jpeg and set compression quality
  • your picture gets placed in the Vandal Hall of Fame where people can see it
  • people can comment on your picture
  • live preview generation
  • several communication methods in it’s own “Vandalize Service”

This was a prototype for a FaceBook app, designed by the UX ( User eXperience) designers at speakTECH back in 2007. I created the back end and front end, making it functional based on some nice specs from the team. The back end was it’s own remoting service called “VandalizeService”.

Portfolio Application

I was looking for a way to display CS4, CS5, Flex 3, and Flex 4 content all in one contiguous Flash experience. Turns out Flex 4 (FlashBuilder) was the best choice! It has proven very stable compared to CS5 as a swf in swf container environment, and does not seem to have any issues with Flash components. Whenever I had free time, I added more items to the portfolio or more features to the portfolio application.

Launch Flash!see it

Perhaps the biggest piece of programming in my online portfolio is the portfolio application itself. It’s not described anywhere in the portfolio, so I’m doing it here.

Here’s a list of features it has:

  • Database Driven: All portfolio items are assembled in a mysql database with info such as title, description, swf path, etc. From the database, you can choose items in the sliding “accordion” component, or the 3D image wheel – both on the left side.
  • Data Services: Data is fetched using Flash Remoting, I wrote the PHP services that feed my ActionScript structured, binary compressed data
  • Integrated WordPress Blog: Portfolio Items described in the blog are linked to the items in the portfolio, and the blog entries can be read while in the site. Click the “W” icons to see.
  • XML Menu system: I can easily add links and items that trigger AS3 functionality. Also, items can be launched in a JavaScript LightBox just by populating the xml
  • Windowing system: Allows you to view multiple items at once and move them around
  • Layout Control: Sizes to any ( decent ) resolution and automatically adjusts the layout to compensate, even when you resize the browser during viewing
  • 3D Item Selector: A custom PaperVision 3D component I built to select items. Selected items have a yellow 3D polygon above them, and highlighted items use a glow effect.
  • Deep Linking: Using Asual SWFaddress, you can link directly to individual portfolio items such as the Slideshow example:
  • Shadowbox: Some portfolio items launch in a JavaScript box overlay. This allows it to launch html content in a separate window without “leaving” the site
  • Full Screen Mode: Click the “Max” button in the top right corner
  • Cascading Windows & Close All functionality: in the Appearance menu
  • Code Generated Wallpaper: in the Appearance menu. Uses a radial gradient

The structure of the portfolio could be reused to develop a large application where interactive modules are loaded and unloaded as needed. Floating windows and dialog boxes, along with the menu system are all elements of this. The code is an MVC ( Model View Controller ) structure that I find easy to update and build on.

The portfolio was rendered dynamically from the database, following a path of mysql -> PHP -> AMFPHP -> Flex.

MP3 Player


  • Stereo output level display
  • Spectrum Display
  • Volume Control
  • Balance Control
  • Stop, Play, Pause, Previous & Next Track
  • Loop feature
  • Time / position display
  • Flash Remoting based playlist, autogenerated

This version was an extension to the original version I made, adding the spectrum display. To avoid copyright issues, I grabbed some royalty-free music clips off the web and put them in a folder. The PHP getDirectory call in PortfolioService grabs all the mp3s in a folder and returns info about them to generate the playlist and play the music. Launch Flash!see it