Build iPhone applications using the Adobe iPhone Packager

Mon Sep 20 05:45:09 2010

For the longest time now, many ActionScript developers have dreamt of using their skills to build iPhone applications, without having to mess around with learning yet another programming language. Adobe released the iPhone packager along with Flash CS5, but a few days prior to that release, Apple and it's lawyers rinsed any possibility of ActionScript running on the iPhone/iPod/iPad etc with bold changes to it's Developer's Agreement, thus leaving the iPhone packager useless. With that, Adobe pledged to discontinue efforts on the iPhone and concentrate on development for Android Devices. As exciting as this was for Android, it left a lot of developers angry, to the extent that some began boycotting Apple products and iPhone Developer get-togethers.

Recent events, however, (and I won't even try to understand the reasons why) have seen a kind of reverse to Apple Developer's Agreement, in that Apple are basically saying that you can now Develop for the iPhone using the iPhone packager (as well as other packagers for various languages) as long as the applications built do not download code. Great news, right?

I was one of the one's who had given up any hope of seeing ActionScript on the iPhone, and I had gone out and found other means of building my first app: Tumble Bee, and to be quite honest, I don't regret it. I learnt a lot from my ordeals and I came out much the wiser.

On the other hand, I am really excited to see what is in store for ActionScript on mobile devices in general and I think that the recent changes really open up the market for developers to build better than ever.

So without any further ado, I would like to post here what I have found out about compiling ActionScript for use on the iPhone.

What you will need

  • Flex SDK including air 2.0+
  • Adobe's iPhone packager
  • Apple provisioning profile (You have to sign up for the Apple Developers license [$99] )
  • p12 certificate (info can be found here)
  • application.xml (I have created an example in the downloadable zip file below)
  • ...patients!

Next download the zip file from the link below. It contains example files that will get you on your way.

iPhone App Example Files Upzip it and inside you should see:
  • icons (folder with icon29.png and icon57.png inside)
  • Default.png

First thing to do is to place the .mobileprovision file that you got from the iOS Dev Center and the .p12 file you should have created inside the unzipped TestCase folder containing the items listed above.

Next, open up Terminal and navigate to amxmlc inside the bin folder inside the Flex SDK you downloaded. (Note* There's more than one way to skin a cat, but this the way I prefer). I have my SDK in my Developer folder so I would type /Developer/SDKs/flex_sdk_4/bin/amxmlc followed by the path the file file inside the zip file you should have downloaded. For example, if the TestCase folder is on your desktop, it will look like this:

/Developer/SDKs/flex_sdk_4/bin/amxmlc /Users/{Username}/Desktop/TestCase/

That will compile the Main file inside the file. You could add -o="location+name.swf" to create a file using a different name.

As you may already know, I like Textmate's ability to run commands very efficiently. If you're like me, you'll probably make a command out of this so you don't have to type all of that every time you want to compile.

Now that you have your .swf, it's time to make the .ipa that will run on your iPhone. You will need to compile using the iPhone packager. I placed mine in a folder called iphone in /Developer/SDKs/. You can place it anywhere you like, but just remember the location. Next make sure you have the .mobileprovision and .p12 in the TestCase folder, cd (change directory) into the TestCase folder and run the following command in Terminal (altering where necessary):

/Developer/SDKs/iphone/bin/pfi -package -target ipa-test -provisioning-profile my_cert.mobileprovision -storetype pkcs12 -keystore my_cert.p12 -storepass {your password} TestCase.ipa application.xml Main.swf Default.png icons

Once that has finished compiling, you should be left with the TestCase.ipa file, which you can then add to iTunes and sync to your device. The actual app in question is a simple program that will show you an example of the ActionScript TouchEvents available - TOUCH_BEGIN, TOUCH_MOVE and TOUCH_END. Just tap and move your finger around the screen and you will see what it does.

Anyway, that's about it. It has a little bit of a learning curve but I'm sure you'll pick it up in no time.

Tumble Bee - my first iPhone app!

Fri Sep 3 12:59:08 2010

'Tumble Bee' has been on the iTunes store for a few weeks now, but I'm am only just now getting round to posting about it here.

Not that I'm advertising or anything (although I suppose a few sales wouldn't hurt), but I have to admit that it's quite addictive. My top score is 263 jumps. If anyone gets higher, please let me know.

But even more importantly, there is nothing better to a programmer than feedback. Please please please feel free to let me know what you think of the game and how it can be improved. I'm all ears towards unbiased, useful comments.

Please visit the TumbleBee iTunes page to check out more about the app as well as the few screen shots that I've put up.

Download Tumble Bee

Fix for jQuery Ajax and json_encode problem

Wed Aug 4 02:12:58 2010

I came across something that really interested and surprised me today. There I was coding happily for one of my latest projects in which I needed to return values from a .php file via Ajax / $.get using jQuery. The aim was to build an array of filtered results from the SQL database and then pass them on to jQuery which would update the HTML on the page and display the results in real time.

I used json_encode( array ) on the PHP side and jQuery.parseJSON(data) on the jQuery side to get the array into something usable for jQuery. The problem was that the array that was jSON encoded was, as I mentioned, filtered on the PHP side. Below is the sort of thing I was doing.

$whatsMissing = array("1","3","4","5");
echo json_encode($finalArray);

Here's what's happening. I've set up an array $checkAgainst which contains values that I want to check to see if they exist in another array I've set up called $whatsMissing. In this simple example, you can probably see that the number that is missing is '2'. So when we run the array_diff() and save the results to $finalArray we should be left with the value '2'. The last thing to do is output this array as jSon using json_encode(). Done! Great ...or so I thought.

The code below is jQuery code and is similar to what I used to parse the json encoded data.

      var obj = jQuery.parseJSON(data);	

This bit of code simply makes contact with the PHP file containing the PHP code above and the returned data is then parsed using jQuery.parseJSON(); and the resulting data is saved to a variable called 'obj'. Simple, right? Wrong! The only thing that was returned seemed to be an empty array. Of course it isn't empty. We know it's not. So what went wrong?

Well, if we tried to return any old array from the PHP code, it would work fine. I noticed the problem was that the jSON returned was a mess. The nodes were out of order and sometimes missing. The culprit, you guess it, array_diff()!

Solving the problem is really easy. I added sort($finalArray); to the PHP file before outputting the data which sorted the data correctly and jQuery was successfully able to parse it properly. What an nuisance!

Firebug-like Capabilities in Safari Browser

Sat Jul 24 11:31:22 2010

For a while now I have been using Firefox because.. well it's simply brilliant. However I always have found that it sometimes moves like a dog and there are just times when I can't afford to wait around. In some cases, switching over to Safari is faster but it doesn't have Firebug features... or at least so I thought.

On Mac OSX just run the following in Terminal (/Applications/Utilities/ ),

defaults write WebKitDeveloperExtras -bool true

and restart Safari. On restart, go to any web page and right click to show a pop up menu. Selecting 'Inspect Element' will pull up something that looks very similar to Firebug.

I haven't really played around with it all that much yet but I assume that it doesn't have features such as those found in Flashbug and PHPbug, but I normally use other solutions to those anyway as I have found better results elsewhere. But for your general HTML and CSS, it looks like a good alternative.

No such file or directory - /tmp/mysql.sock

Sun Jul 11 05:02:51 2010

I've been playing around with a little Ruby on Rails recently and while trying to connect to my MAMP development databases, I came across the following error when using rake db:migrate.

No such file or directory - /tmp/mysql.sock

I have to admit that this baffled me for a while, but after reading around on the net, it suddenly hit me. 'I'd been having one of my stupid moments', I thought as I added the following line to my database.yml file

socket: /Applications/MAMP/tmp/mysql/mysql.sock

I'd been looking for a file in a place where one had no right to be. Why on earth would there be a mysql.sock when there was no sql database? All my development database reside inside MAMP, so it makes sense then that that is where I would find my mysql.sock file.

I realize that this isn't really a big problem for most, but I thought that this could be a potential blind spot for other PHP developers new to Rails and thought I'd best help out.

Most recent posts

  1. Getting around Apple's silly rules for iOS 10
  2. Localising App Names for iOS and Android
  3. Today - Powerful To-Do App Now Available on iOS & Android
  4. New app 'Gem Plinko' Released on iOS
  5. Spooktacular Creeps For iOS & Android

Search site:

Apps by

Click the app icons to see more info