A few days ago Powerflasher released a new version of their logging tool SOS. I have used it in the past but stopped using it because I switched to Mac. Since the new version also runs on OS X I gave the new version a try and it works nicely.
I have posted a little extension for SOS about two years ago and now I made a little update which is easier to use. It works the same way as the TraceTarget I already blogged about.
The project is hosted on Google Code.
In you Flex project simply put this line into you main MXML:
And add the namespace: xmlns:logging=”com.soenkerohde.logging.*”
The rest works like described in my post about TraceTarget.
This version also supports multiline logs which can show up collapsed and can be expanded:

The application code for the example above:
<!--[CDATA[ import mx.logging.Log; import mx.logging.ILogger; private static const logger:ILogger = Log.getLogger("Main"); private function init():void { logger.debug("debug"); logger.info("info"); logger.warn("warn"); logger.error("error"); logger.fatal("fatal"); logger.info("This is a multiline log example\nwith a second line."); } ]]-->
Last week I attended my first online live concert on Ligx.de. The band was Thrice, a post hardcore band which of some of you might know. I was skeptical with the user experience but was surprised positively. Of course it is not comparable with a real live concert but attending the entire show with support band, sound check etc. gives you the live atmosphere. You know things are happening really in that moment and you get no 20 seconds YouTube clip with bad sound quality like there are so many from trillion different concerts.
And not to forget since generally I am only blogging about Flash/Flex stuff, the Ligx website is build with Flex and I am pretty sure the streaming part is done with the Flash Media Server and the backend is done with Ruby and RubyAMF.
Since last week FlexUnit has a new home on Adobe Open Source and I thought it would be the time to finalize my post about FlexUnit with AIR and Ant which I had in the pipe for a longer time.
You can run Ant via command line or from within Eclipse which provides an Ant panel if you use Flex Builder plugin version. If you are using Flex Builder standalone check this article about how to install Ant it afterwards.
You have to download Peter Martin’s JUnitTestRunner class which was build to test within the Flash Player and not AIR so it uses XMLSocket to hand over the test result. AIR has the capability to write directly to the users hard drive so we will add this functionality by subclassing JUnitTestRunner.
Download the AIRAntUnitTest project and import it into Flex Builder.
You will get four errors because Peter Martin’s JUnitTestRunner class is not delivered in my zip. So please download it from his blog (last Donwload link at the end of his post) and add it to the directory flexunit/junit.
You have to change the JUnitTestRunner class slightly to make my subclass work:
- Change the following member variables from private to protected: reports, totalTestCount, numTestsRun
- Change the createXMLReport method modifier from private to protected
Now the project should build without errors.
Change the build.xml and enter the path to your installed Flex SDK by defining the property flex.sdk.dir (in my case D:/tools/flex_sdk_3.0.2.2113).
Your setup is complete and now you have two options to launch you unit tests:
The first option is to use the visual runner of the FlexUnit project. Right-click the AIRAntUnitTest.mxml and choose Run As->Adobe AIR Application. This launches the debug launcher and since no parameter is passed the visual runner get’s the test suite and is started (onInvoke event listener). The result should look like this:

The second option is to use Ant. If you want to launch it from within Eclipse open the Ant panel (Window->Show View->Other->Ant->Ant). Now drag the build.xml from the AIRAntUnitTest project into this panel and it should look like this:

Here you see the five different Ant targets. The build target is default and calls clean, compile, run-tests and generate-reports. Double-click “build” to run the tests.
- clean removes the bin-release and reports directory
- compile compiles the SWF for AIR
- run-tests opens the AIR application in the debug player (ADL) which get’s closed with exit code 0 if all tests passed and 1 if there were failures or errors
- generate-reports uses the junitreport feature of Ant and handles the xml results generated by Peter’s JUnitTestRunner and written to hard disk with the AIR file API
The generated reports look like this:

If you want your build to fail when failures or errors come up change the attribute failonerror to “true” in the run-tests target.
With this approach you could run your unit tests automatically on your build server and do Continous Integration so you would have a self-testing build.
Many thanks to Peter Martin for his JUnitTestRunner and I hope this AIR approach is usefull for some of you guys.
To skin a TextInput you can define a custom BorderSkin which you can create with the Flex Skin Design Extension. But what do you have to do to have a custom disabled skin?. With CSS you can only set the backgroundDisabledColor.
To have a custom disabled skin you have to subclass the TextInput control. In this class the setters for editable and enabled are overwritten to switch the stylename:
package controls { import mx.controls.TextInput; public class ExtendedTextInput extends TextInput { override public function set enabled(value:Boolean):void { super.enabled = value; selectStyle(value); } override public function set editable(value:Boolean):void { super.editable = value; selectStyle(value); } private function selectStyle(enabled:Boolean):void { styleName = enabled ? getStyle("enabledStyleName") as String : getStyle("disabledStyleName") as String; } } }
The CSS to define reference to the BorderSkin the looks like this:
ExtendedTextInput
{
enabledStyleName:"enabledTI";
disabledStyleName:"nonEnabledTI";
}
.enabledTI
{
border-skin: ClassReference("TextInput_borderSkin");
}
.nonEnabledTI
{
border-skin: ClassReference("TextInput_borderSkinDisabled");
}
There were a lot of news and posts about Flex and open-source so I thought it would be nice to summarize it.
Grant Skinner has posted a wonderful summary about common source code licenses.
Matt Chotin asked for feedback on suggested projects related to Flex. Personally I would love to see an ORM framework like suggested by Christophe Coenraets which works with BlazeDS.
Alistair McLeod and Steven Webster blogged about the move of Cairngorm from the Adobe Labs wiki to Adobe Open Source.
I just received the Adobe Edge Newsletter which covers an article about the art of open-source license by Dave McAllister.
Here a list of some client side open source software I use the most to develop Flex/AIR:
Here a list of Flex frameworks (InfoQ Flex Framework article):
and IoC frameworks:
and component libraries:
and animation/UI frameworks:
and 3D engines:
And much more if you check out OSFlash or search Google Code for “flex” or “as3″.
And for the server-side there is not less. Adobe recently proposed AMF support for the Zend framework and of course BlazeDS which fits wonderfull into a stack with Spring and Hibernate!
I thought I share some Eclipse goodies which might simplify your workflow if you use Eclipse/Flex Builder on a daily base and don’t know them yet.
Linked Resource
Sometimes you can not avoid absolute paths within your Flex/AIR project settings (.project, .actionScriptProperties, .flexProperties) because you define for instance an include for a library.
When you put these project settings under version control you have got a problem as the absolute paths only works on your machine and especially cross operation system like Windows and OS X.
The solution is to use the Linked Resources feature of Eclipse:

DOCUMENTS is there per default and I added CATALINA_HOME to specify the location where I installed Tomcat. When you now use a path in your property files like for instance .actionScriptProperties you can now use ${CATALINA_HOME} or Eclipse even substitutes the paths with the linked resource variable automatically for you.
Memory / Heap Size
Edit your eclipse.ini (on Mac show package contents) to increase the memory you give to Eclipse which will increase the performance a lot. My eclipse.ini looks like this but figure out what works for your machine depending on the Ram you have:
-showsplash org.eclipse.platform --launcher.XXMaxPermSize256m -vmargs -Xms512m -Xmx768m -Djava.net.preferIPv4Stack=true
It is always good to see how many memory Eclipse uses so enable it in the Preferences->General->Show heap status and after that you see the info on the bottom right of your Eclipse window:

If you start Ant scripts from Eclipse which is the way I use it all the time you can also run out of memory and I posted a couple of weeks ago how you can change the settings.
Label Decorations
If you work with a version control system (if not you should start today) Label Decorations help a lot to have a quick view on the status of a file.

Working Set
I like to work with one workspace because I have to re-configure all settings if I would switch to another workspace location. When you have many projects in your workspace it is easy to loose focus so try to group you projects into Working Sets.
Link with Editor
Ok, this is a small one but it helps if you don’t know it. The navigator view has a little icon with two yellow arrow in opposite direction. Click it and now every time you select a file tab in the editor on the right side the corresponding file in the navigator get’s selected so you know were you are.
Shortcuts
If you see CTRL/CMD it is control-key on Windows and CMD aka Apple on OS X. Some shortcuts are not different cross this operation systems.
- Open Resource (CTRL/CMD-SHIFT-O): Let’s you browse all files in your workspace and while you start typing the files are filtered. This dialog also support wildcards like ? and *.
- F11: Run Debug
- CTRL-F11: Run
- CTRL-H: Search
- CTRL/CMD-G: Find declarations
- CTRL/CMD-SHIFT-G: Find references
- CTRL/CMD-ALT-G: Find text
- CTRL-O: Quick Outline
Clean and unexpected problems
Sometimes you focus a situation in Eclipse where you say “This can’t be!” but obviously it can. So when you have unexpected problems first try to clean the affected projects (Project->Clean). If this does not help close Eclipse and restart it via console with the parameter “-clean”. If this does not help maybe your workspace is corrupted so try to switch to a new workspace. The last step to nail down Eclipse problems is a fresh clean Eclipse download and start from the beginning which is also not that much of work since Eclipse does not depend on an installation routine.
Do you have some Eclipse goodies to share?
When you build a multi-window AIR application you have to care about the parent Sprite/DisplayObject you set for popups opened with the PopupManager and Alert.
In a single application you probably used this:
PopUpManager.addPopUp(yourView, Application.application as DisplayObject, modal);
Problem is when you call this from a view which lives in a native window and not in the main application window that the popup opens in the wrong window which looks pretty ugly.
The solution is simple: Use parentApplication instead. parentApplication is defined in UIComponent and is
“A reference to the Application object that contains this UIComponent instance.”
So the code should look like this:
PopUpManager.addPopUp(yourView, parentApplication as DisplayObject, modal);
The same works for Alerts which can trap you even more since the parent parameter is optional:
Alert.show("your text", "your title");
If you run this code within an opened native window the Alert will be shown in the main application window. Here you have to set the parent explicitly and cast it to Sprite instead of DisplayObject:
Alert.show("your text", "your title", 4, parentApplication as Sprite);
If you open Alert windows from classes which do not extend UIComponent (like for instance a Cairngorm Command) you do not have a reference to your parentApplication which makes it more difficult. My current approach is to path a parent parameter of type Sprite within the CairngormEvent which is dispatched by a view which extends UIComponent.







