Timeless Songs

Posted in Eric Daugherty on August 29th, 2009 by admin
There are great songs, and then there are timeless songs. Songs that are appreciated generation after generation, and throughout the different stages on one's life.

I think part of the test of a timeless song is how an acoustic, or 'unplugged' version holds up. When you strip out all the energy and 'noise', do you still have something that you love?

I just saw an old ('75) acoustic performance of Thunder Road (thanks Merlin), and it reminded me of why the song is so great. When you strip it down to its core, it is still amazing.



MTV Unplugged popularized the idea of acoustic versions of rock (and other genres) songs. As a Bon Jovi fan, I've enjoyed a couple Unplugged versions of Living on a Prayer, but the classic one is the '89 MTV Awards:



Acoustic versions often give you a closer and more intimate connection with the lyrics. While this is generally true, and certainly true of the previous two songs, I don't find this Dylan Unplugged version of Like a Rolling Stone creates that closer connection. I think it is too 'busy'. To many instruments, too much noise. Take it as a contrast to the previous two. It is still a great song, but I much prefer the more distilled versions by Bruce and Jon.

Building Flex Applications with Gradle

Posted in Eric Daugherty on August 25th, 2009 by admin
In a recent post, I touched on my frustration with Maven and my interest in other build tools. Gradle looked interesting (Grovy DSL with Ant integration). I've been playing with building a Flex app, so I thought I would see if I could get Gradle to build it. Since Adobe provides custom Ant tasks as part of its SDK distribution, it should be easy. In fact, it is.

Assumptions:
  • You have downloaded the Adobe SDK (or Flex Developer)
  • You have a sample Flex (or Air) app to build.
  • You have Gradle downloaded and installed.
The first step is to create a Gradle build file (build.gradle) in your Flex application directory. To test your Gradle install, put a simple Hello World task:

task hello << {
println "Hello World"
}

You can then run gradle hello from your command prompt. It should echo back:

:hello
Hello World

Now you need to 'install' the Flex Ant Task Jar. This can be found in your Flex SDK Install under the ant directory (sdk_install/ant). There are a couple ways to install this. The easiest is to put it in the lib directory under your GRADLE_HOME directory. You can also specify the classpath in the taskdef command, but I'll leave that as an exercise for the reader...

Once you have the Flex Ant Tasks installed, you can create your Gradle build script. Here is a straight foward compile script:

ant.FLEX_HOME="c:/Program Files/Adobe/flex_sdk_3"

ant.taskdef(resource: "flexTasks.tasks")

task compile << {
ant.mxmlc(file: "src/Main.mxml") {
}
}

You will need to change the FLEX_HOME value and Main.mxml to your specific environment/app, but that is it. You can then execute gradle compile from your command prompt and compile the application.

If it is an Air app, you will need to add configname: "air" to the mxmlc task definition so it uses the Air configuration. Otherwise, you will likely see: Unable to locate specified base class 'mx.core.WindowedApplication'

To build the Air package for your application, you will also need to call the script file included with the SDK. You can find a sample of the ANT version of this here.

This example is more a sample of how easily Ant tasks can be used in Gradle than the overall power of Gradle. But it does demonstrate that Gradle can be used to build anything that has Ant tasks, and that is a great start.

Drunk On Software Episode 16: Dion Almaer and Ben Galbraith founders of Ajaxian.com

Posted in Drunk On Software, Jon Rose on August 23rd, 2009 by jonr

In this episode we chat with Dion Almaer and Ben Galbraith founders of Ajaxian.com, and currently working on Bespin at Mozilla.

Build Tools

Posted in Eric Daugherty on August 20th, 2009 by admin
I've said it before, I find Maven annoying. I've even explored other build tools like Simple-Build-Tool, which I like, but I'm not sure I love.

Now Steve Ebersole from Hibernate joins the ranks of the frustrated Maven users. He is frustrated with Maven's module setup, something I've seen first hand on my current project.

Based on the comments on his post, it seems that Gradle is becoming a popular alternative, I'll have to check it out.

Simple-Build-Tool is also mentioned, though I've only used it for Scala projects so far, I find it interesting but also a bit difficult to fully understand. It's flexibility and use of Scala is powerful, but has the common side-effect that it isn't obvious how to accomplish something, or what a configuration line really does. I like the fact that it leverages Maven's standard structure, allowing you to easily test Maven projects with SBT.

I think Ant could also be salvaged, if it adopted the Maven directory conventions and then allowed configuration from there, but I'm not sure that it the best approach. It may just be time to move on.

What do I really want? A tool that provides simple setup for 'standard' projects, but allows the flexibility and power for fine grained control when I want to devaite from the 'norm'.

Episode 16: Dion Almaer and Ben Galbraith founders of Ajaxian.com

Posted in Drunk On Software on August 19th, 2009 by admin

In this episode we chat with Dion Almaer and Ben Galbraith founders of Ajaxian.com, and currently working on Bespin at Mozilla.

Resources:

FlexMonkey 1.0 Beta 2 and the FlexMonkey User Guide are here!

Posted in FlexMonkey on August 18th, 2009 by admin

Announcing the immediate availability of FlexMonkey 1.0 Beta 2! After the very successful Beta 1 launch last month, we are pleased to bring you Beta 2. Since Beta 1 had very frew issues, Beta 2 is much more of an enhancement than a bug-fix release.

Most notably, Beta 2 introduces “MonkeyLink”, which allows you to link FlexMonkey directly into your target SWF. If you have had any problems dynamically loading your application through the FlexMonkey Console or the MonkeyAgent, you can now instead compile MonkeyLink into your application SWF, and then launch your application directly. Using MonkeyLink, you can test virtually any Flex or AIR application. Dynamic SWF loading with the Console or the MonkeyAgent are of course still supported so you also continue to have the option of testing SWFs without having to first recompile them.

Download FlexMonkey 1.0 Beta 2 now at http://flexmonkey.gorillalogic.com/gl/stuff.flexmonkey.download.html!

The long-awaited FlexMonkey User Guide is available at http://flexmonkey.gorillalogic.com/gl/stuff.flexmonkey.documentation.html! Weighing in at nearly 60 pages, the FlexMonkey User Guide is like having your very own Eric Owens!

Happy testing!

FlexMonkey 1.0 Beta 2 and the FlexMonkey User Guide are here!

Posted in Stu Stern on August 17th, 2009 by admin
Announcing the immediate availability of FlexMonkey 1.0 Beta 2! After the very successful Beta 1 launch last month, we are pleased to bring you Beta 2. Since Beta 1 had very frew issues, Beta 2 is much more of an enhancement than a bug-fix release.

Most notably, Beta 2 introduces "MonkeyLink", which allows you to link FlexMonkey directly into your target SWF. If you have had any problems dynamically loading your application through the FlexMonkey Console or the MonkeyAgent, you can now instead compile MonkeyLink into your application SWF, and then launch your application directly. Using MonkeyLink, you can test virtually any Flex or AIR application. Dynamic SWF loading with the Console or the MonkeyAgent are of course still supported so you also continue to have the option of testing SWFs without having to first recompile them.

Download FlexMonkey 1.0 Beta 2 now at http://flexmonkey.gorillalogic.com/gl/stuff.flexmonkey.download.html!

The long-awaited FlexMonkey User Guide is available at http://flexmonkey.gorillalogic.com/gl/flexmonkey/FlexMonkeyUserGuideR1b2.pdf! Weighing in at nearly 60 pages, the FlexMonkey User Guide is like having your very own Eric Owens!

Happy testing!

Deceptive Marketing

Posted in Eric Daugherty on August 11th, 2009 by admin
There is a great post on 37 Signals about 'Little Green Lies'. I've looked at the exact same label ('98% naturally derived ingredients') and thought the same thing.

What does that even mean? EVERYTHING is 'derived' from something natural at some level. The sad part is that marketing like this works.

John Hughes

Posted in Eric Daugherty on August 7th, 2009 by admin
With John Hughes' passing yesterday, it is appropriate to pay tribute to his life and work.

For me, he was the writer and director of the movies that defined my adolescence. As a writer, he had an amazing string of hits from 83-87 with:
To write that many great movies every year for 5 years is amazing, especially since he directed over half of them himself. I've seen every one of these movies many times and enjoyed them all. Add other hits like The Great Outdoors (1988) Uncle Buck (1989), National Lampoon's Christmas Vacation (1989), and Home Alone (1990), and it is an amazing career.

Growing up in Chicago, John Hughes' movies always had a special appeal. They were often set in Chicago or its suburbs, and represented Midwestern suburban kids. Me.

Here is a great montage on YouTube set to a great song...


Drag-and-Drop in Flex 4

Posted in Justin Shacklette on August 5th, 2009 by admin

The Flex 4 gods were kind to us developers when they made the great decision to leave the custom drag-and-drop support unchanged. We just do what we’ve always done: detect the user is trying to drag something via mouseDown or mouseMove and then add both dragEnter and dragDrop event handlers to the drop target. So there is nothing in this post that’s not basically identical to Flex 3, except the coolness of FXG (which you can easily mimic with Degrafa in Flex 3).

Simple Drag-and-Drop

I’ll begin with a basic Flex 4 application. We have two draggable graphics (a Rect and an Ellipse) in the left panel, and a target panel on the right:

<?xml version="1.0" encoding="utf-8"?>
<s:Application
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark">
 
    <fx:Script>
        <![CDATA[
            imports...
 
            private function mouseDownHandler(e:MouseEvent):void {
                DragManager.doDrag(e.currentTarget as IUIComponent, null, e);
            }
 
            private function dragEnterHandler(e:DragEvent):void {
                DragManager.acceptDragDrop(e.currentTarget as IUIComponent);
            }
 
            private function dragDropHandler(e:DragEvent):void {
                e.currentTarget.addElement(e.dragInitiator);
            }
        ]]>
    </fx:Script>
 
    <s:Panel title="src" width="100" minHeight="133" x="10" y="10">
        <s:Graphic width="80" height="80"
                mouseDown="mouseDownHandler(event)">
            <s:Rect ... </s:Rect>
        </s:Graphic>
 
        <s:Graphic width="80" height="80"
                mouseDown="mouseDownHandler(event)">
            <s:Ellipse ... </s:Ellipse>
        </s:Graphic>
        ...
    </s:Panel>
 
    <s:Panel title="target" width="100" minHeight="133" x="120" y="10"
            dragEnter="dragEnterHandler(event);"
            dragDrop="dragDropHandler(event);">
        ...
    </s:Panel>
</s:Application>

Reading the code above, each draggable Graphic has a mouseDown handler that calls DragManager.doDrag() to initiate dragging. And the target Panel calls DragManager.acceptDragDrop() on dragEnter and addElement() on dragDrop. Note that since Panel is a Spark container we must use addElement() to re-parent the dropped graphic (the familiar addChild() is still used for Halo containers).

Our simple drag-and-drop app (view source enabled):

Flash is required. Get it here!
Using a FXG Drag Proxy

In the example above, the moment you start dragging a component the drag proxy is displayed. By default, the proxy is just a bounding rectangle with an alpha value of 0.5. This is particularly noticeable and lame when you try to drag the pink circle. Thankfully, we can use any display object for the drag proxy (more specifically any component that implements IFlexDisplayObject which includes UIComponent and any of its descendants). Why not use a FXG graphic? It is, after all, a major piece of the new hotness that is Flex 4.

First, we need to modify the mouseDownHandler to instantiate our FXG graphic. Then we just add it as the forth parameter to the DragManager.doDrag() call.

private function mouseDownHandler(e:MouseEvent):void {
    var star:Star = new Star();
    DragManager.doDrag(e.currentTarget as IUIComponent, null, e, star);
}

And here is Star.mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:Graphic
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        width="80" height="80">
 
    <s:Path data="M 119,0 L 148,86 238,86 166,140 192,226 119,175 46,226 72,140 0,86 90,86 Z"
            y="2" scaleX="0.3361345" scaleY="0.3361345">
        <s:fill>
            <mx:SolidColor color="#FFCC00" />
        </s:fill>
    </s:Path>
</s:Graphic>

Bang! We have a gold star as our drag proxy. Try it out for yourself (view source enabled):

Flash is required. Get it here!
Dynamic Drag Proxy

Dragging a gold star is pretty cool, but how can we make the drag proxy look exactly like the drag source? For that we need a dynamic drag proxy.

First, for reasons which will become clear in a moment, we need to revise our app to make each of the drag source graphics into a separate component. So the left Panel changes to contain these custom components:

<s:Panel title="src" width="100" minHeight="133" x="10" y="10">
    <graphics:Square fillColor="#6666FF"
            mouseDown="mouseDownHandler(event)" />
 
    <graphics:Circle fillColor="#FF66FF"
            mouseDown="mouseDownHandler(event)" />
 
    <graphics:Star fillColor="#FFCC00"
            mouseDown="mouseDownHandler(event)" />
 
    <graphics:Square fillColor="#66FF99"
            mouseDown="mouseDownHandler(event)" />
 
    <s:layout>
        <s:VerticalLayout gap="10" horizontalAlign="center" paddingTop="10" paddingBottom="10" />
    </s:layout>
</s:Panel>

Next, we again modify the mouseDownHandler, this time we instantiate our drag proxy dynamically. We use reflection on the incoming drag source to get its name, instantiate it, adjust a few properties, and pass it to the DragManager.doDrag() call.

private function mouseDownHandler(e:MouseEvent):void {
    var dragSrc:Graphic = e.currentTarget as Graphic;
 
    //create a proxy by creating a new "copy" of the drag src
    var className:String = getQualifiedClassName(dragSrc);
    var klass:Class = getDefinitionByName(className) as Class;
    var proxy:* = new klass();
 
    //set the proxy's properties to match the src + sexy drop shadow
    proxy.width = dragSrc.width;
    proxy.height = dragSrc.height;
    proxy.fillColor = (dragSrc as IDraggableGraphic).fillColor;
    proxy.filters = [new DropShadowFilter()];
 
    DragManager.doDrag(dragSrc, null, e, proxy);
}

The real reason for the reflection gymnastics, plus the need to package each drag source as a custom component, is the lack of a deep copy operation on UIComponent. If we could just clone the drag source, we’d be golden. Alas, for many reasons, the most obvious of which is that it is a huge pain in the ass, there is no such thing as deep copy. In our case, my work around was to package all the visual stuff of each draggable item into a single custom component with a known API (all the custom graphics implement IDraggableGraphic). Then I reflect, instantiate, configure, and pass to doDrag().

Our dynamic drag proxy now matches the drag source, plus the sexy drop shadow. Check it out (view source enabled):

Flash is required. Get it here!
Files

NOTE: All code was built with Flash Builder 4 Beta 1.