Declarative programming in Flex

When building applications using Flex (for AIR or Flash Player), you can use declarative programming to specify part of your user interface. The declarative language of Flex is XML-based and called MXML.

Here’s a simple app in Flex/MXML:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
title="Hello Rich Internet Application"
backgroundColor="#FFFFFF"
>
<mx:VBox horizontalAlign="center" horizontalCenter="0" verticalCenter="0">
<mx:Button
label="Click Me"
click="mx.controls.Alert.show(
'ActionScript and Flex are a match made in heaven!',
'Flex Rocks!');"
/>
<mx:Label
fontSize="24"
fontWeight="bold"
color="#1A49DF"
text="Flex Makes RIA Development Easy"
/>
</mx:VBox>

</mx:WindowedApplication>

Here’s the equivalent app in JavaFX:


/*
* HelloCompiledJavaFX.fx - A "Hello World" style, but slightly more
* sophisticated, compiled JavaFX Script example
*
* Developed 2008 by James L. Weaver (jim.weaver at lat-inc.com)
* to serve as a compiled JavaFX Script example.
*/
package mypackage;

import javafx.ui.*;
import javafx.ui.canvas.*;

Frame {
title: "Hello Rich Internet Applications!"
width: 550
height: 200
background: Color.WHITE
visible: true
content:
BorderPanel {
top:
FlowPanel {
content:
Button {
text: "Click Me"
action:
function():Void {
MessageDialog {
title: "JavaFX Script Rocks!"
// This string has a newline in the source code
message: "JavaFX Script is Simple, Elegant,
and Leverages the Power of Java"
visible: true
}
}
}
}
center:
Canvas {
content:
Text {
font:
Font {
faceName: "Sans Serif"
style: FontStyle.BOLD
size: 24
}
x: 20
y: 40
stroke: Color.BLUE
fill: Color.BLUE
content: "JavaFX Script Makes RIA Development Easy"
}
}
}
}

(from http://java.sun.com/developer/technicalArticles/scripting/javafx/ria_1/)

Collier Trail

Blogging in the middle of the forest…

The Mechanics Monument—labor omnia vincit

Bronze sculpture by Douglas Tilden in San Francisco at Market, Bush and Battery.

Dedicated in 1901, this sculpture also known as the Donahue Memorial Fountain, celebrates Peter Donahue, a successful San Francisco industrialist.

Peter Donahue arrived in the Gold Rush era San Francisco in 1849 and soon opened a small blacksmith shop at the corner of 1st and Mission under a tent. Over the years, Donahue’s business grew into the first foundry on the West Coast, Union Iron Works, which would manufacture the first printing press in the West. Donahue also founded the first streetcar of San Francisco, Omnibus Street Railway, and the San Francisco/San Jose railroad line, still in use to this day by thousands of commuters every day. Donahue also founded the San Francisco Gas Company, which would become the Pacific Gas and Electric company after merging with Edison Electric, still in business today as PG&E.

The monument was a source of inspiration in the rebuilding of San Francisco following the 1906 earthquake and fires. Still close to its original location, the modern tower behind attest to the success of the rebuilding efforts.

The San Francisco of today owes much to the vision and energy of its early pioneers. It is quite remarkable how a single person had such an impact.

The fountain is inscribed with the motto labor omnia vincit. ”Work conquers all”, indeed.

Temple of Forgiveness

This shot of the Temple of Forgiveness that I took at Burning Man 2007 is now my most interesting picture on Flickr, beating the picture of the Starry Bamboo Mandala I took last year and “Naked Lady” from the Kona Classic.

Methodist Church in Bodie

Bodie is a once prosperous mining town in the Eastern California Sierra Nevada, 30 mi north of Mono Lake. It became a boom town in 1877, and by 1879 it was the second largest city in California, behind only San Francisco, with over 10,000 residents. It was the first city in the US with a long distance transmission of electricity. Now it remains in a state of arrested decay.