Active Ashfield’s Conversion Challenge

June 18th, 2009

Active Ashfield's Conversion ChallengeA few weeks back I was commissioned by Bug Interactive to develop a viral game for the Active Ashfield initiative and to promote the launch of their new website. The brief was to develop a sports-themed game that featured their two food-based characters (Brocky and Peggy) which would promote healthy eating and an active lifestyle.

The result is Active Ashfield’s Conversion Challenge, a game that tasks the user with scoring as many conversions as they can within the two minute time limit. It’s not quite as easy as it sounds though, as you have to factor dynamic wind (both in terms of direction and speed) and variable kicking power into your aiming!

To play the game or for more information on it, head over to the game’s page in the Projects section.

Tip: for the best chance of scoring, aim high and time your kick carefully!

Bookmark and Share

Author: Gareth Categories: Flash development, Video games Tags:

Carbonite: online backup software

June 9th, 2009

BackupAround a year ago now I was working at my computer one night. Suddenly it made a few clicking sounds and immediately I knew that this was bad news. Unfortunately, while I considered my immediate backup options and tried to decide how best to save all of my files before my computer finally died, it blue-screened on me and refused to start up again. Yep, catastrophic disk failure. It hadn’t even given me enough time to make some essential last-minute backups.

I spent the next hour or so researching the best way to get my data off a broken hard drive and found a forum where one guy had frozen his drive in the freezer, arguing that the extreme cold would slightly shrink the parts inside and bring any contacts closer together. Why not try that? The disk had already refused to yield anything to the six different bootable recovery disks that I had tried so I felt that I had nothing to lose.

I wrapped the drive in a plastic bag to prevent moisture from getting inside it and placed it in the freezer. The next morning I removed the drive and found it to be so cold that my fingers stuck to the metal. I connected the drive to my computer and turned it on, not really knowing what to expect. Amazingly, it booted into Windows. I managed to move everything of any importance off the drive onto a second drive before the disk finally warmed back up to room temperature and failed again.

After buying a new drive and re-installing Windows and all of my other software, the first thing I did was look for a backup solution. I found one in Carbonite. Carbonite automatically and securely backs up the contents of your hard drives for roughly £30/year and offers unlimited storage. It’s continuous and automatic, secure and encrypted. It’s also available for Mac. The peace of mind that I get from knowing that even if my flat was to burn down to the ground, all of my music, my photos, my work – everything – is all backed up off-site on secure servers.

As a happy customer I’d recommend it to anyone.

Bookmark and Share

Author: Gareth Categories: Software Tags: , ,

Quak Wordsearch

June 8th, 2009

Quak WordsearchQuak Wordsearch is an application that allows you to play a different wordsearch game every time you view it. Whenever you load the game it selects at random from a list of words that you have specified and places these words on the grid in random locations. To see this process in action, try refreshing your browser a few times on the game screen!

The application is ideal for puzzle websites, and as it allows for you to print the game out and complete it on paper it is also ideal for use in schools as an after-lesson activity.

For more information on the game, to play it or to buy it, please visit the Quak Wordsearch page.

Bookmark and Share

Game Wrapper

May 23rd, 2009

Xbox 360 joypadFollowing on from the previous post about protecting your code with obfuscation, an obvious statement would be that the best way to protect your work is to ensure that no-one gets a copy of it! Of course such drastic measures would prevent anyone from seeing your work at all and make developing a product totally pointless, but what if there was a compromise between the two? What if there could be a difference between what you gave people and what they actually saw on-screen when they ran that file?

Having a “key” file (which I’ll refer to as the Key) to access a “resource” file (which I’ll refer to as the Resource) centrally also means only ever having one location for that Resource, and so if you were to spot a bug in your Resource or if you wanted to add a feature, you’d only have to replace a single file for that change to permeate instantly throughout the internet.

Since your Resource would only ever be run centrally, this also opens the door for tracking. You’d be able to see who was accessing your resource and how often. If the Key was to provide information on where it was being run from you’d also be able to control the locations that had access to that Resource, and in effect you’d be making an “intelligent” Key that only worked for certain people.

All of this serves as the foundation for a piece of software that I have developed and called the Game Wrapper. Although called the Game Wrapper because I wanted to use it to serve my games to different websites, the same technology would actually work with any type of resource – games, animations, elearning etc.

I use Game Wrapper to serve games to various online gaming websites, so I know that every site has the same version of the game and if I ever want to add or change something in any of my games, I make that change once and upload the new file to my server and that new version instantly becomes the version that everyone is playing.

Game Wrapper also allows me to specify whether games are allowed to be played locally on a user’s machine or online only. If online only, I can also specify which websites are allowed to play it and this ensures that no-one steals the game to use it without my permission. If the game is ever run from a site that hasn’t been added to the Allowed list, I get an email that tells me which game has been run illegally and from which website.

I can also serve adverts before the game starts to load or I can serve the game right away – whatever’s best for any particular game.

Developers will know that when a Flash file downloads another Flash file, the downloaded file is stored in “Temporary Internet Files” so the scenario with which I opened the post about ensuring that users don’t ever get access to the Resource isn’t strictly true, but despite physically being on that user’s machine the file will only run if it’s run from the host website, only if it’s run from a Key, and only if the user is on the Allowed list.

Both the Keys and the Resources are also run through SWF Encrypt for an added layer of security.

Bookmark and Share

Author: Gareth Categories: Flash development, Video games Tags: ,

Protecting your Flash code

May 23rd, 2009

PadlockDue to the unsecure nature of Flash, I’ve always been wary of having my work decompiled and its code re-used without my knowledge or consent. By default Flash offers very poor protection against this. While it’s undoubtedly impossible to prevent this from happening completely (despite various security software vendors’ claims), you can make the process so difficult that most people will give up trying.

Of course, not all Flash work will be a target to such piracy but games and elearning products can be targets because the cost and time of developing these resources legitimately can be quite high.

An easy way to protect your work against decompiling is to run your work through an obfuscator. I use Amayeta’s SWF Encrypt, and while a file that has been obfuscated in this way is larger in terms of file-size, the protection that this process offers your code is well worth it. Obfuscating your file like this makes the code almost impossible for a human reader to know what’s going on inside it, much less be able to steal it or change it for their own needs. In a decompiler the code will appear to be nothing more than a load of gibberish, and in fact some decompilers will be tripped up by the obfuscated file and won’t even open it at all.

Bookmark and Share

Author: Gareth Categories: Flash development Tags:

Alex Stocks gets a soaking at Oakwood Park

May 3rd, 2009

Here’s Alex Stocks, my brother in law, getting a soaking at Oakwood Park over the summer. The fact that he was so close to the end of the slide when he fell off the sled just makes it all the funnier in my opinion.

Bookmark and Share

Author: Gareth Categories: Comedy Tags: , ,

Cyclomatic complexity in Actionscript

May 2nd, 2009

ActionscriptCyclomatic complexity is a software metric used to measure the complexity of code. Specifically, it directly measures the number of linearly independent paths through a method. Although not a rule, generally speaking the quality of the code can be inversely proportional to the cyclomatic complexity value, so the lower the score, the higher quality the code.

One of the best programs that I’ve found for measuring the cyclomatic complexity of Flash Actionscript is SourceMonitor. This handy little freeware tool will give you the cyclomatic complexity values of your classes and of the individual methods within those classes so you can see exactly what requires attention in the event of a high score. It also gives other feedback too, such as number of lines of code and the number of methods per class among others.

If you fire up SourceMonitor with the intention of using it for Flash, you’ll notice that there is no preset for *.as files among the half-dozen or so presets available. That’s fine. Select the C++ profile and change the file extensions to *.as, then proceed. You’ll also have to make sure that your class files are saved with ANSI encoding and not UTF-8, though most decent text/code editors will take care of this for you.

Why should you care what cyclomatic complexity value your code gets? Well, apart from the warm glow you get inside from knowing that your code is well-written and elegant, there is a practical reason for it as well and that is the reduction of potential bugs. The more complex the code, the more difficult it is to keep track of what’s going on and the higher the risk of bugs creeping into your classes.

The accepted values for cyclomatic complexity are as follows:

  • 1 – 10: a simple program with a very low risk of bugs
  • 11 – 20: a more complex program with a moderate risk of bugs
  • 21-50: a very complex program with a high risk of bugs
  • > 50: untestable and obviously a number you want to stay well away from.

The highest value I’ve personally seen on an Actionscript class is 74, but you didn’t need to know that value to see that the classes were badly written. The classes contained switches that executed exactly the same code on ten different cases and there were duplicated methods in most of the classes. The code was written by a contractor, and as far as I know that was the first and last job that he was given. The name of the product that features this code is something that I’ll have to keep to myself though!

Bookmark and Share

A class that both works and doesn’t work

May 2nd, 2009

ActionscriptThis morning I was looking forward to making some progress on a Specsavers application that I’m working on. I had been thinking about some of the finer details of how it was going to work last night and was ready to blast through the code and have a good portion of it written by the end of the day.

It was not to be.

I had an application class, and this application class would instantiate different child classes that were responsible for different “screens” depending on which “screen” the user had selected. This is an approach that I have used a thousand times before, so it really didn’t take much time to have all the code in place. However, when I published the application I found that it didn’t work. The first screen would load fine, but when trying to load the second screen I found that the application would just remain blank. What was going on? The file was compiling without any errors and all I was doing was instantiating different classes depending on a string ID. For all intents and purposes, the class that was failing to work was identical to the one that was working.

This was weird!

As I was using a method that I had used countless times before, I thought that perhaps the third-party wrapper that I was using was interfering with it so I stripped out its code. Nope, still didn’t work. I stripped out my recently-edited button manager class… nope, still didn’t work.

After stripping out everything apart from the absolute bare essentials and STILL ending up with only the first screen, I made a simple test file from scratch using different smiley faces as screens. Again, an application class called two other classes depending on which button I pressed, and each of these classes attached a different movie clip to the stage. It worked fine, as it had done so many times in the past.

So, what the hell was different between that and my non-functioning Specsavers app?!

I traced out the object variable that was being linked to the different screen classes and for the first screen it came back as [object object] as expected, but for the second screen it was coming back as undefined. I put a “wtf?” trace above and below the line that instantiated the second screen’s class and yep, they popped out in my trace so the line WAS being executed – it just wasn’t doing anything.

I went about transplanting the smiley faces code into my Specsavers app line by line and when finished, it worked. I then tried it again with the original class and once again I was met with a blank screen as once again it failed to work for me.

What the HELL was going on here?! My time was being consumed by a problem with attaching a movie clip to the stage! Was I missing something? Had I accidentally smoked a vast amount of weed before starting work that day?

In the end I had two classes – my original Specsavers class and my smiley face class – identical apart from one small detail. The Specsavers class was located within a subdirectory and was being imported at the top of the application class. The smiley face one was located within the same directory as my SWF and so did not need to be specifically imported at the top of the application class. The smiley face one worked while the Specsavers one did not.

I put the smiley face one inside the sub-directory and imported it – right there, it stopped working. I took the Specsavers one out of the sub-directory and put it into the same directory as the SWF and deleted the import line and yeah, it worked.

There was nothing special about the name of the sub-directory. It’s not a system name or a reserved name or anything like that.

So, to summarise, there is some kind of weird quirk that – for some reason – means that Flash treats classes that are imported slightly differently to those that aren’t. I’ve never come across this before and I have no idea if I’ll come across it again, but while searching for potential reasons for my non-functioning class on Google today only to find absolutely no clues at all, I hope this post might prove useful to someone else.

Bookmark and Share

Author: Gareth Categories: Flash development Tags: