Archive for the ‘Web’ Category

Air for Android experiences

I’ve just launched my first Air for android app on the android marketplace here, a mobile app for quizmash, and I thought it would be a good time to share my experiences developing it.


The whole app was developed in the mighty Flashdevelop, the current release of which has off the shelf project templates for air mobile development. You simply create a new project, run the CreateCertificate.bat file once, and then uncomment the android-debug call in the run.bat file and you’re good to go. From there on in it’s just like developing any other Air app except this one is running on your little mobile screen. I honestly don’t think they could have made it any easier.

One thing that can be a gotcha if you’re trying to get started is if you want to debug on your phone and not just run the app you need to set the DEBUG_IP address in SetupApplication.bat to the ip address of your PC, and you must have your phone on the local wi-fi network, as air can’t debug over USB like you can when building a native app.

One of the thing’s you’ll miss when developing in Air vs native is built in touch scroller behavior. Building one of these from scratch was a bit of a challenge, and although I think i got pretty close, it doesn’t quite have the smoothness that you get with native. Hopefully over the coming months I can make some adjustments to further increase performance, and release the source for it once it’s up to scratch.


Dealing with intermittent internet connections is a much bigger deal when developing for mobile, so it’s been important to catch data errors, and handle them gracefully. For now the app passes the user to a re-connection screen, which pings the server and carries on from there. Over time I want to have a more elegant solution to this problem.

One thing that has been a source of frustration is the soft keyboard which has caused all sorts of issues. Some of which i tracked down to the fact that my test phone has Swype installed, which while an awesome text entry app, doesn’t play nicely with Air textfields. Swype is still beta so hopefully they’ll sort out some of there issues. Also with the stock keyboard I’ve run into occasions where the keyboard opening causes the selected textfield to lose focus, which then closes the keyboard. I’ve had to put in a few hacky workarounds for now but this is definitely something i want to improve on.


You can get the app for free on the marketplace here. Please let me know what you think of it, and give it a review on the marketplace. If all goes well with it I’ll look at compiling a version for iOS so iPhone and iPad users can join in.

No Comments

Introducing Quizmash

Back in the mists of time I was studying for my Adobe Flash certification, and struggled to find many example questions on the web.

There were a couple of sites that had a few, but they were always limited to the questions the person who made them had written. I thought it would be cool if someone built a site allow anyone to post questions on a subject, so that the pool of available questions would grow over time.

Flash forward a couple of years and behold, Quizmash! It lets users not only post questions, but subjects too, so if you have some knowledge on any subject, technical or trivial, post it here, and hopefully someone will find it useful in their hunt for example questions.

It’s only got a couple of example questions in there to start with, and there’s plenty of features to add, and no doubt bugs to squash, so right now I’m looking for any of you flash geniuses out there to come up with some questions about Actionscript 3, or indeed any other technical subject you can think of to get the ball rolling.

Ok, get mashing!


More PureMVC bits and bobs

Thanks to everyone who came to the Sydney APUG, and listened to me blather on about PureMVC again. I’ve uploaded a zip of my flashdevelop template files here.

Special thanks to Chris and the Rocketboots crew… except Robin. ;P


WebDU 2009 slides and sourcecode

I’ve uploaded the slides and source for my WebDU presso on PureMVC here. Thanks to all who came and listened.


Building a RESTful webservice client in flash, and fighting all the way.

I’ve recently finished struggling with writing a client for a RESTful webservice in flash, and let me tell you it’s been a long painful process, one which i thought i’d like to share. First a (hopefully not too inaccurate) primer on what REST is all about.

RESTful web services use the full http specification in order to send an recieve data. That is, instead of just using POST and GET like most web applications, they also make use of PUT and DELETE, amongst others. Unlike SOAP webservices in which the body of the http message contains contextual information about a request or response, they use HTTP response codes and headers to convey this information in a much more simple lightweight way. I thoughroughly reccommend RESTful webservices by O’Reilly if you want to learn all about them.

They’re becoming increasingly popular, and so I decided I was going to build one for a current job. After scraping the rust off my php skills I managed to get a fully restful webservice together, and feeling pretty pleased with myself I turned to the easy part. Building a client for said webservice in flash.

Well that turned out not to be the easy part.

Problem 1 – No PUT or DELETE

First up I dicovered that the URLLoader class does not support any http methods other than GET and POST. I suspect that this has something to do with the way flash routes requests through the browser, however REST webbservices can accommodate this limitation (as it’s apparently quite common) by using something called overloaded POST, where the request is always sent as a POST with the real request method embedded as a url variable or in the message header. And here we hit problem two.

Problem 2 – No empty POSTs

When sending a POST request from flash, if there is no body in the request, then it is always sent as a GET. Ouch! Although it is sloppy, I figured I could get around this by putting junk vars in the body to stop this. Now because this webservice is out on the public web, it uses HTTP basic authentication as a security layer. To do this an encoded username/password string is sent in the headers of the request. If the correct key is not sent, the browser issues a 401 Unauthorised http code, to challenge the client and inform it what kind of authentication method is being used. You’ll see this in use when your browser pops up a login dialog for some web pages. Flash 9 and above does not allow some blacklisted headers to be sent to the server. Including, you guessed it…

Problem 3 – No authentication headers allowed

Thats right folks. Flash player 9 does no allow the Authentication:Basic header to be sent. 9.0.115 Allows it but only if the flash cross domain policy file on the server explicitly says so. Even if the swf is on the same server. Now in this case I could modify the cross domain file as it was my own webservice, but what about the thousands of webservices that I don’t control? Anyway I couldnt be sure on which domain the client would sit, so I decided to hack my webservice to look for an alternative custom header if Authentication:Basic wasn’t present. This was a horrible way to work around this, and I had no idea what I would do if I needed to talk to a third party webservice that used basic authentication. The next step was to recieve the response from the server to see if the login was correct, and…..

Problem 4 – No support for http status codes

The http spec defines a whole raft of http status codes for use in communicating the status of a request. 200-ok means success, and i’m sure you’re familiar with 404-not found. The problem is even though the URLLoader class has a status event, with a status code property, it doesnt actually work. First up is the fact that in some browsers all codes other than success are returned to the flash player as a 0, which isn’t actually a status code. Then there’s the fact that if anything other than 200 is recieved, flash fires the status event and stop the data from being recieved. This is even if the status code is not an error, but something such as a 201-created which is a subtype of the 200 success code.

So where next?

Well after banging my head against flashes broken HTTP support, i came across a potential solution in as3httpclientlib. An open source library that uses the AS3 socket classes to emulate the entire http specification. This is an awesome library and an absolute joy to use, in no time I had built my client and all was well with the world. Until I uploaded it.

Problem 5 -Socket policy files

This is a dark realm to be dealing with indeed. The current flash player does not allow socket connections to any server, unless a socket policy file is available, even if the client is in the same domain. Ok I thought i’ll just drop one next to my cross domain file. unfortunately its not that simple. The policy file needs to be served by a socket policy server running on port 843 of the same domain, or via the same socket the request was made to in response to a specific socket call. So basically I was screwed. I didnt have enough access to the server to set this up, and even if I could you need to be a sysadmin wiz to do so. I really dont think Adobe could have made this any more dfficult, and though there are articles on how to do this  on their site, they seem not be written for the people most likely to need them, flash developers. This means that the beautiful as3httpclient is esentially only useful for AIR development.

Picking myself up.

In the midst of all this a freind of mine had suggested just giving up and writing an rpc style proxy on the client side to talk to. I told him I refused to be beaten (though I later was, curse my foolish pride) but this planted the seed for my solution. What i have basically written is an extension to as3httpclientlib, that altough behaves the same from the users view, actually interprets full HTTP requests into text based POST meta data, that is sent to a php proxy file. This proxy then make the real request to the server, encodes the response in a similar meta format, then returns this to the flash player via URLloader behind the scenes. This is then deserialised into what appears to be a seamless as3httpclientlib response, et voila.

This is all in early alpha of course, but it seems to be working for me so far. The beauty of it being that this should enable flash to talk to ANY restful webservice, without all the pain you can see i’ve been through. Please have a play with it and let me know what you think. And so i humbly present to you, the snappily titled as3httpproxyclientlib. Its up on google code, under the same MIT licence as its parent library. It requires you have the parent library in your classpath, but otherwise, short of uploading the proxy file to a server of your choosing, and passing this url to the client instance, should behave in the same way. It does require you have CURLlib installed on your php server, but i believe thats pretty common, and I’m open to people contributing proxies in other languages and for other server configurations. In fact any contributions at all are welcomed as i’m no php developer and it’s probably leaves huge room for improvement.

Let me know how you get on, and don’t let flash get you down.


Locking FLA’s under version control

We’ve recently moved over to SVN as our version control system. This system, among other features allows you to request a lock on specific files checked out from the version control system. This means nobody else on your team can check that file in until you have either finished editing and checked it in, or released the lock.

When it comes to FLA files this is great, as unlike actionscript source code, FLA files cannot be automatically merged and so having two people working on the same FLA at the same time creates all kinds of problems, with lost hours, and even lost work.

The problem with optional locking, is that you may not know a file has been locked until you go to check it in, at which point you may have worked on it for hours and so we are presented with the same problem, having to manually merge two versions of the same FLA file.

SVN solves this by allowing you to set the property svn:needs-lock on any file. This means that when a user checks the file out they receive it as read only, and to make it writeable they need to request a lock for the file, at which point their SVN client notifies them that somebody else has the file locked so they need to request that person checks the file in. It also allows you to set auto-props, which are properties to apply to all files of a certain type that are checked into the system. In our case any .FLA files.

This falls down in one respect though. If you are not opening the file from windows explorer (in the case of tortoiseSVN) where you would see the grey icon indicating that a file is read only, but rather from your IDEs recent documents menu, or from a tool that provides a different view to the file system such as FlashDevelop, it relies on whatever tool you use to edit that file telling you that a file is read only. Unfortunately Flash does not warn you when you open a read only FLA. It just opens the “save as” dialog when you try to save the file. This a potential point where you could be facing a file merge, or even worse, lost work.

To get around this I’ve put together a JSFL script that detects when you open a file and examines it’s properties for the read only attribute, then pops up a warning to get a lock from SVN before working on it. Hope people out there find this useful. To use it you need to save it to C:Documents and SettingsusernameLocal SettingsApplication DataAdobeFlash CS3enConfigurationToolscheckReadOnly.jsfl

you can download it here

* Check read only script
* Warns you about opening read only files in Flash IDE
* By Phil Douglas 2008
trace = fl.outputPanel.trace;
function onDocumentOpened(){
var currentDoc = fl.getDocumentDOM();
nativePath = currentDoc.path;
uriPath = nativePath.split(':').join('|');
uriPath = uriPath.split("").join("/");
uriPath = 'file:///'+uriPath
attributes = FLfile.getAttributes(uriPath)
alert('This file is read only. If it is in SVN you should request a lock before working on it.');
fl.removeEventListener("documentOpened", onDocumentOpened);
fl.addEventListener("documentOpened", onDocumentOpened);


WebDu 2007 slides and notes

You can download the slides and notes from my talk on e-learning here

I’ll be writing a wrap up of the conference soon, but it’s amazing how much work piles up in two days away from the office. :P


Speaking at WebDU 2007

I’ve now been officially announced on the list of speakers for this years WebDu conference. It’s totally exciting, and also my first time presenting at this type of thing, so should be a heap of fun (and fear).

I’m doing a session on E-learning from a developers perspective. Covering some things that will hopefully be new to people from a normal web dev background, and sharing a few things that i learned the hard way. You can find out more about the session here.

It’s amazing to be involved in something that attracts so many awesome people. Make sure you grab me to say hi even if you don’t see the session itself.


Another flashden file approved – MP3 player

Just a quick one. Flashden have approved another of my items for sale, a skinnable XML driven Mp3 player. Enjoy you crazy disco kids!


Flashden goes official

Flashden has finally removed the beta from their name. Time to load up on stock flash. You see my creations on my portfolio page.

No Comments

  • SetPageWidth