FlashDevelop Haxe Class Not Found

I’m playing around with Haxe as part of my on-going search for a good cross platform development language. I recently got a “Class Not Found” error with FlashDevelop when I tried to add the Actuate library to my project.

I’d already installed the library via nme (haxelib install actuate) and I was able to import the code in FlashDevelop, but couldn’t build the swf. After much searching, I found some info from Joshua Granick

First include the library in the NMML project file:

<haxelib name="actuate" />

Then in FlashDevelop, go to Project > Properties, pick the Compiler Options tab and expand Libraries. Add the new library (“actuate”) on its own line. Adding it to your project file is all you need to compile properly, but FlashDevelop still needs you to add it in your project settings in order to get code completion.

Posted in Uncategorized | Leave a comment

Manually adding .apk package to Android

Once you have created the .apk package, use the Android Debug Bridge (adb) to transfer the package to your Android device for testing. The adb was previously found in the SDK in the tools directory. The adb is now located in platform-tools.

The command to transfer the .apk is:
adb install pathTo/yourPackageName.apk
After the .apk is installed for the first time you may get an error message when you try to install it again: Failure [INSTALL_FAILED_ALREADY_EXISTS].

The adb requires a flag to re-install the app:
adb install -r pathTo/yourPackageName.apk
Note that this keeps any existing app data.

To uninstall the app:
adb unistall yourPackageName.apk
More information can be found on the developer site (http://developer.android.com/guide/developing/tools/adb.html) and also via the command line adb help

Posted in Uncategorized | Leave a comment

Global Lightness in People’s Republic of China

欢迎’ (Huān yíng!)

Some of the Flash-based English language games I created a few years back are being used in the Hong Kong Special Administrative Region. I don’t really expect to be flooded with requests for work, but it nice to know that the resources still meet a need.

Hopefully they will bring in something like the 30, 000 US visitors that use them every month ;)

Posted in Business | Leave a comment

Error: Resource entry main is already defined

I got this strange error after editing my main.xml file: “Error: Resource entry main is already defined”, with main.out.xml being created in the same folder.  A quick search then revealed that this is Eclipse, helpfully trying to transform the XML that I had edited. This is the default behaviour whenever the editor has a XML file open and in focus.

I tried to modify the Eclipse launch Configuration as follows:

Open Window>Preferences>Run/Debug>Launching>Launch Configuration.

Check the “Filter checked Launch configuration types:”

Then scroll through the list to “XSL” and check this box too, but the issue remained whenever the XML file had the focus.

The solution I used was to change the launch configuration by opening Window>Preferences>Run/Debug>Launching, and then checking the “Always launch the previously launched application” box.

Posted in Android, Eclipse | Leave a comment

Installing Eclipse for Android Development

I’ve set up Eclipse using the  Java Enterprise Edition(Java EE) with Java Development Kit 1.6 (JDK6 – I’m glad it is not just me losing track of what version is what) in order to play around with Live Wallpaper and native Android applications. The installation process was a breeze compared with my previous experience with the IDE.

Configuring it to use the Android Developer Tools (ADT) plug-in was also very quick and easy. The developer guide is really clear and easy to follow – nice work!

I’ve run through the samples and got some Paint on the Canvas, but I miss Flash’s smooth vector shapes :( Next stop vector graphics…

But before that, I’ve installed the color theme, picked a nice dark theme (“inkpot”) and turned off the bold text.

Posted in Android | Leave a comment

HTC Desire USB Drivers

In order to connect the HTC Desire to your computer, you need the latest USB drivers.  The simplest way to install these is to run the HTC_Sync.exe (which can be found on the phone).

As part of the initial system check the exe will allow you to install the necessary drivers (and you don’t actually need to install the sync app.)

Posted in Android | Leave a comment

Blackberry Playbook App Approval

I’ve just had confirmation from Blackberry that my first Playbook application has been approved!

Compared with some reports, it has been quite quick, with the whole process taking a little over two weeks, so perhaps things are speeding up at the test house.

There are another two currently being reviewed.  All three apps are compiled to run as AIR for QNX, were very easy to port from existing AS3 applications and fun to make. I can’t wait to get my hand on an actual Playbook. I’ve had to work around the gesture events for one of the apps, and plan to modify them all to suit the specifics of the Playbook development.

My first app:

Posted in Uncategorized | Leave a comment

Blackberry Playbook Design and Development

I have just finished another application for the Blackberry Playbook and fired it off to Blackberry for the approval process.

The thing that I most enjoyed about the project was that I got to actually play around with the graphics and come up with some design options. It makes a nice change to design for a fixed screen size (The Playbook has a 1024 x 600 pixel screen) and also create a splash screen and custom icon.

Splash screen

The application was a simple I Ching generator that creates hexagrams (six line graphics) made up of two separate three line sections (trigrams). Each line is either a yin or yang element and is further complicated by the possibility that the line will “change” from one type to the other.

I wanted the application to be a simple as possible and also have a clean aesthetic. Given that the trigrams are based around natural phenomena, I chose a subtle, pared down colour palette.  I used a old trick from Joshua Davis: taking a photograph, and then extracting out some actual colour values.

With each trigram having its own colour, I set the colour of the lines to match each trigram, in order to make the component parts more distinct. The yin/yang element was also communicated by slightly lightening the colour where the line “changed”.

I used a simple grid to order the information and looked for appropriate fonts to fit the simple, calm, visual look that I was aiming for. The challenge was in setting out the two panels so that they worked with varying amounts of text:

Another key element in the project was the use of a simple audio track to indicate the casting of the hexagram. Again, an appropriate ‘natural’ sound effect was required and I settled on the use of wind chimes to tie in with the natural calm feel.

The final element in the design was a number of simple transitions, used to convey the changes. As a hexagram was created the screen was cleared and then new hexagrams where created. The appearance of the two panels was deliberately delayed so that second panel slid on screen after a short delay. Only a single button was used in the application to generate new set of hexagrams and this was also set so that it faded in after a few seconds delay. This was done to allow the viewer to read the details with minimal distraction and also worked to prevent repeated generation of hexagrams.

Posted in Actionscript, AIR, Blackberry, Design | Leave a comment

How to debug Flash

Debugging Flash applications can often be thought of as a dark art, but with practice and a few techniques it can turned into a scientific exercise.

One of the key things when fixing errors to to be patient and take your time to do it properly. Before you start, it is worth considering side-stepping the error by fixing it the hard way, eg removing the offending section and starting again and estimating how long such an approach would take. This is then a useful measure for the amount of time to spend debugging the ‘easy’ way. Take your time, and do it right first time.

I’ve found Steve McConnell’s Code Complete to be a big help in improving my coding as I moved from Flash design to focus more on development. Obviously, by following good development practices as you code, you will reduce the number of error that are made. However, sometimes you will have to debug an issue and the following broad approach is very useful:

* Reproduce the error
* Find its source
* Fix it
* Test it

Repeat the Error

Reproducing the error is the first step in fixing the code. Given Flash’s very nature this can often be a series of actions and events. You are trying to avoid guesswork so it is very useful to make notes on the steps taken to repeat the error.  take you time to ensure that you understand the problem.

Once you can reliably repeat the error, make a copy of the code. You’ll need this later once you’ve made a dozen changes and forgotten exactly what you modified. You can then ‘diff’ the two copies to see what has changed.

Find the Error

The next step is to figure out why it is happening. I find it useful to start by add trace statements in the code to track the flow of data. Depending on the nature of the error, it is also useful to trace out specific variables, such as event information and error codes. The aim is to come up with a very narrow test case that triggers the error, but don’t expect to do this on the first attempt. It is usually the case of trying an initial idea, testing it out, reviewing the results and then repeating the process. Remember that not proving your idea can be just as useful in helping identify the issue. Also try to reproduce the error in different ways.

By working through the tracing data in a methodical way, you can narrow down the suspicious region in the code. Good places to look are classes that have had defects before and areas of code that have recently been changed. Another useful technique is “confessional debugging”: explaining the issue to someone else. In order to explain it, you have to go through the analytic process and it can help you solve the problem yourself.

Having identified the offending block of code, a useful technique is to use a binary search ( i.e. commenting out half the code at a time to see where the error is.) to further identify what exactly is causing the error.

Compiler Errors:

As3 compile errors can often be misleading eg the classic Error # 1046

1046: Type was not found or was not a compile-time constant:

which can mean a missing import statement or a symbol on stage with an instance name that is the same as a class name. It is worth noting that AS3 compilers can be funny when detecting multiple errors. Don’t worry if you get a page full of errors – fix the first one and then re-compile the code.

That said, it is worth turning on Strict and Warning Mode in the compiler and treating any warning as errors.

Fix the Issue

Remember to fix the actual cause of the error and not the result: treating the problem and not it’s symptoms. Fixing the symptoms is making the code worse. It is also wise to tread lightly when going through code – only change the code for a good reason.

Don’t be tempted to refactor as you go through – make one change at a time and test it. Changes are tricky enough on their own and you want to be sure that the change you made actually fixed the issue (if not then remember to remove it)

Finally once you are sure that the issue is fixed, then ‘diff’ the new version with the old to check that you haven’t added any unnecessary code. It is also worth checking the program for any similar types of errors in other places.

Posted in Actionscript | Leave a comment

Flash debug tools

To assist in debugging Flash applications, there are a range of tools that I find useful to have in my utility belt:

Flash Debug Player: This is a key element in displaying log errors in Firefox and a range of players are available from Adobe dependig on your OS and browser.

Firefox: This is the best browser to use when testing/debugging web projects. Specifically the Firebug and Flash Tracer plug-ins.

DeMonsters: An excellent debugging application – In addition to displaying object properties and methods, it also allows those values to be manually tested. There are facilities for stepping through movie clips visually and for taking bitmap snapshots of objects. It also monitors the frames per second of the SWF and the total memory (NB this is the total used by the Flash player and not just the SWF being examined) Version 3 is due out soon: http://demonsterdebugger.com/

Fiddler (Windows only): Fiddler is an excellent utility for tracing traffic over HTTP. It is very useful when trying to identify issues with loading and saving data to and from the Flash SWF.

An important tip when using it locally is to include a dot after the localhost in the address, so instead of http://localhost:1234/myApp/…,
use http://localhost.:1234/myApp/… (it’s subtle, but notice the extra dot after localhost and before the port number).

IDE: Both flashDevelop and FlashBuilder4 have built-in debuggers that are very useful for stepping through code to follow the sequence of code as it is executed. It is beyond the scope of this introduction, though more information can be found below http://labs.adobe.com/technologies/flashbuilder4/tutorials/debug/

Once you have your toolkit set up, the next step is to use them to find and fix errors in your code. I’ll detail my approach in another post.

Posted in Actionscript | Leave a comment