Wednesday 31 December 2008

Apache Ant + Ivy on OSX

In order to get Apache Ivy working from the command-line on OS X, I did the following:

(Get the current versions of Ant and Ivy)

(or copy the folder to /usr/local and create a symlink to ant)

(For the sake of simplicity, I'm just copying the ivy jar into Ant's lib folder):

(Set the home for the current session - this should be added to bashrc in order for it to work permanently)

Test with:

(You should see something like)
Apache Ant version 1.7.1 compiled on June 27 2008

If so, you can go into one of the ivy example folders:

If this has worked, you should see:

[java] standard message : hello ivy !
[java] capitalized by org.apache.commons.lang.WordUtils : Hello Ivy !


If you want to use ivy in Eclipse, all you should need to do is make sure the jar is in the buildpath.

I found this guide pretty useful for installing Ant in OS X:

Tuesday 23 December 2008

Compiling AS3 classes on the command line

As an update to my previous posting - I've just discovered this:

If you've installed the free Adobe Flex SDK, you can use the command line to compile .as files, making it possible for you to use any editor you like to author your Actionscript files.

Obviously one of the reasons I was so interested in using IntelliJ is because you can compile and run your flash movies through the debugger (as you can with the FlexBuilder eclipse plugin). However, this may well be useful for someone.

First cd to wherever you installed your SDK - in this case, for Leopard:

It'll load a flex-config.xml file (in the frameworks folder), write out any errors / warnings and then tell you that it has created:

ClassName.swf (and output the size in bytes).

Also (may be worth noting):

This approach could (possibly?) be useful if you were building an application that would compile as3 classes as part of its execution, or if you were using ANT to compile an as3 app as part of a build process (there are a few blog postings on this too).

Quick disclaimer:

It should probably be said that it's currently unclear to me whether mxmlc.jar is part of the SDK or whether it's part of the eclipse plugin. If you were planning to use it as part of an application, you would need to check licencing requirements with Adobe.

Saturday 20 December 2008

Editing/Authoring Actionscript 3 Classes in IntelliJ IDEA

I wanted to see whether it was viable to use IntelliJ 8 as an IDE for creating complete Flash applications (for writing Actionscript). By default, the application allows you to create Flex applications and creates a "HelloWorld" app to get you started. But at first it was unclear how I could write AS3 classes and compile them without jumping over to flash or using FlexBuilder.

I spent some time today dealing with issues regarding certain flash Objects (namely the Stage) being "null" and after some reading, I discovered this was to do with timing - I read around online and after looking in many places, I pieced together this mxml file:

This replaced the HelloWorld.mxml that IntelliJ provided and it does two things:

1. Waits until "applicationComplete" (so the 'stage' exists).

2. Runs a function called init(), this instantiates and places it on the stage (as a 'raw' child element). Once shell has been instantiated, init() is run and this can do whatever you like really - instantiate other classes, place objects on the stage, etc.

IntelliJ will use the Flex SDK's compiler to 'build' all of your project .as files; all you need to do is tell it where to find the Flex 3 SDK (in Leopard, it was installed by default in: /Applications/Adobe Flex Builder 3 Plug-in/sdks)

Once you've got some code written in the shell, you can use the IntelliJ debugger to run the app, inspect trace statements and so on. Although it's not quite as easy to "get up and go" with IntelliJ as it is with the FlexBuilder plugin (or application), it still makes authoring AS3 possible using IntelliJ.

Example (will trace out the stage width and height):

Hope this is useful to someone who had wanted to know how to use IntelliJ as an Actionscript IDE and who was finding the same issues I had been running into.

Sunday 7 December 2008

STAX - Parse an XML Doc and print out all the attributes of that element

This might be useful for anyone looking for a simple example for Stax - this will run through a locally saved xml file and write out the element and all its attributes:

Saturday 6 December 2008

Getting the finder to display the $PWD

If you want to be able to see the path to the folder you're looking at: