Getting started with Spring Actionscript (Spring IOC/DI for Flex)

June 26th, 2009 No comments

I recently started integrating the SpringActionscript (formerly named “Prana Framework”) into my current Flex application. SpringActionscript is an Inversion of Control (IOC) and Dependency Injection (DI) framework for Flex that is syntactically based on the popular Java Spring Framework.  While there are several contending IOC frameworks for Flex, if you use Spring in your Java projects it is a natural decision to go with SpringActionscript.  Developers that switch between Java and ActionScript can make a mostly comfortable transition without a great deal of ramp up and learning a new syntax.

So I started with a sample project using the current released version 0.7.1 and followed the instructions in Chapter 2 in the Getting Started portion of the documentation.  The documentation is straight-forward and pretty clear on what you need to do.  However, when I went to run the project, I could never get it to recognize my objects defined in the applicationContext.xml file.  It would compile fine, but upon trying to access a named object at run-time (‘bean’ in Java speak)  I would get the following error message:

Error: An object definition for ‘exampleObject’ was not found.
at org.springextensions.actionscript.ioc.factory.supp ort::AbstractObjectFactory/getObject()[C:\Users\Christophe\Documents\Adobe Gumbo MAX Preview\spring-actionscript\core\src\main\actionscript\org\spring extensions\actionscript\ioc\factory\support\Abstra ctObjectFactory.as:138]
at SpringActionScriptExample/applicationContext_completeHandler()[D:\repo\trunk\source\SpringActionScriptExample\src \SpringActionScriptExample.mxml:46]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at org.springextensions.actionscript.ioc.factory.xml: :XMLObjectFactory/_doParse()[C:\Users\Christophe\Documents\Adobe Gumbo MAX Preview\spring-actionscript\core\src\main\actionscript\org\spring extensions\actionscript\ioc\factory\xml\XMLObjectF actory.as:343]
at org.springextensions.actionscript.ioc.factory.xml: :XMLObjectFactory/_loadNextProperties()[C:\Users\Christophe\Documents\Adobe Gumbo MAX Preview\spring-actionscript\core\src\main\actionscript\org\spring extensions\actionscript\ioc\factory\xml\XMLObjectF actory.as:315]
at org.springextensions.actionscript.ioc.factory.xml: :XMLObjectFactory/_loadNextConfigLocation()[C:\Users\Christophe\Documents\Adobe Gumbo MAX Preview\spring-actionscript\core\src\main\actionscript\org\spring extensions\actionscript\ioc\factory\xml\XMLObjectF actory.as:291]
at org.springextensions.actionscript.ioc.factory.xml: :XMLObjectFactory/_onLoaderComplete()[C:\Users\Christophe\Documents\Adobe Gumbo MAX Preview\spring-actionscript\core\src\main\actionscript\org\spring extensions\actionscript\ioc\factory\xml\XMLObjectF actory.as:241]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

I worked on this issue trying different combinations for a few hours before finally giving into defeat and posting a help request on the SpringSource forums.  Within a day the helpful members on the forums quickly pointed out that the namespace and schema defined for the <objects> node in my applicationContext.xml file was using a namespace and schema definition intended for the upcoming 0.8 version release.   So it turns out the published documentation is just a little ahead of the game and as soon as 0.8 is released, this should be a non-issue.

Here was my applicationContext.xml file using the namespace and schema locations as defined by the current documentation:

<?xml version="1.0" encoding="utf-8"?>
<objects xmlns="http://www.springactionscript.org/schema/objects"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.springactionscript.org/schema/objects
                              http://www.springactionscript.org/schema/objects/spring-actionscript-objects-1.0.xsd">

    <object id="exampleObject">
      <property name="firstName" value="John" />
      <property name="lastName" value="Doe"/>
      <property name="age" value="41"/>
    </object>
</objects>


An here is my modified, working applicationContext.xml file using the older namespace and schema locations for versions older than 0.8:

<?xml version="1.0" encoding="utf-8"?>
<objects xmlns="http://www.pranaframework.org/objects"�
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.pranaframework.org/objects
                             http://www.pranaframework.org/schema/objects/prana-objects-0.6.xsd">

    <object id="exampleObject">
      <property name="firstName" value="John" />
      <property name="lastName" value="Doe"/>
      <property name="age" value="41"/>
    </object>
</objects>


That’s all it took!  All is up and working now.
Here is my full working sample source code project:

SpringActionscriptExample.zip

Download ZIP

For the full details of this issue, please see this forum thread:  
http://forum.springsource.org/showthread.php?t=73932

Categories: Adobe Flex

RefCardz: FREE Cheat Sheets for Flex Developers!

June 23rd, 2009 No comments

Free Flex Related RefCardz at refcardz.dzone.com:

These are great reference cards to have handy if you are a Flex developer.


Very First Steps in Flex
Bruce Eckel and James Ward, author of First Steps in Flex

Features include Hello, World, Web Services, Remoting and Messaging with Java, Hot Tips and more.



Flex & Spring Integration
Jon Rose and James Ward
Contents Include: About Adobe Flex, About Spring, Why Adobe Flex and Spring, Integrating Adobe Flex and Spring, Hot Tips and More…


Flex & Spring Integration
Jon Rose and James Ward

Contents Include: About Adobe Flex, About Spring, Why Adobe Flex and Spring, Integrating Adobe Flex and Spring, Hot Tips and More…




Flexible Rails: Flex 3 on Rails 2
Peter Armstrong, author of Flexible Rails: Flex 3 on Rails 2

Features include Overview of Rails 2, Overview of Flex 3, Flex 3 and Rails 2 Together, Building a Flex + Rails Application, Hot Tips and more.





Categories: Adobe Flex

What’s New in Adobe Flex 4

June 23rd, 2009 No comments

I just came across this article by Jon Rose over on DZone:

What’s New in Adobe Flex 4

This article provides a nice concise overview of the upcoming changes in Flex 4, including many that I mentioned in my previous post.  A must read if you have no idea about the new features and offerings in Flex 4.


Categories: Adobe Flex

Highlights from Adobe CF & Flex User Group Tour – San Antonio

June 23rd, 2009 No comments

Terry Ryan, Adobe Platform Evangelist

I just returned tonight from the Alamo Area Cold Fusion Users Group special event hosting Terry Ryan, Adobe platform evangelist.  Terry gave a great overview covering the new Flex 4 enhancements, Spark,  Flash Catalyst, Centaur, and Bolt.  Unfortunately we ran short on time and did not get very far into Flex Builder Flash Builder 4.0, but the group consisted mostly of Cold Fusion centric developers and Terry appropriately tailored the discussion to focus on their interests.  Personally, not being a CG guy, I would have preferred much more in depth discussion on Flex 4 and Flash Builder 4, but I did get to see some really cool demos on what capabilities are coming soon and the strategic direction and logic behind the Flex 4 changes.


Some of the key highlights for Flex that I noted are listed below …


Bidirectional (Two-way) data binding expressions

The data binding capabilities in Flex 3  are limited to one-way directional binding, Flex 4 will provide a new syntax for data binding expressions that you want to be bidirectional or two-way.  Simply adding the ‘@’ symbol at the beginning of the binding expression turns it into a two-way binding expression.

@{bindable_property}

In the example below we will define the text properties of two text input components with an in-line tw0-way binding expression that will keep the text value of these two components in sync.

  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:TextInput id="t1" text="@{t2.text}"/>
      <mx:TextInput id="t2"/>
  </mx:Application>


Additionally if you prefer using the binding  <mx:Binding> tag in your MXML, there is a new twoWay property that also allows you to define the two-way binding expression .

  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:TextInput id="t1"/>
      <mx:TextInput id="t2"/>
      <mx:Binding source="t1.text" destination="t2.text" twoWay="true" />
  </mx:Application>

More information on the two-way binding expressions can be found here:
http://opensource.adobe.com/wiki/display/flexsdk/Two-way+Data+Binding


Advanced CSS

css_terminologyAdobe has significantly enhanced the CSS support for Flex 4 applications.  These enhancements include Multiple class selectors, ID selectors,  descendant selectors, pseudo (state) selectors.

For detailed information on these new additions, please see the Adobe specification:

CSS Advanced Selectors - Functional and Design Specification


Here is a great presentation overview video covering the new CSS enhancements.

FlashCamp San Francisco: Advanced CSS in Flex 4






Enhanced States Syntax / In-line State Syntax

A new way to more cleanly manage component changes across state changes.  In Flex 3 this could create quite ugly code because ever change to a state required a series of mx:SetProperty, mx:AddChild, and mx:RemoveChild tags for each component property in each state.   This could quickly get out of hand and in practice, it made the states mechanism less desirable to use and manage.

Here are Adobe’s code examples:

This is the the Flex 2/3 method of defining states and component changes in states:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:states>
        <mx:State name="newCheckbox">
            <mx:AddChild relativeTo="{vbox}">
                <mx:CheckBox id="checkbox" label="Checkbox" />
            </mx:AddChild>
        </mx:State>
        <mx:State name="newTextArea" basedOn="newCheckBox">
            <mx:AddChild relativeTo="{vbox}">
                <mx:TextArea id="textarea" />
            </mx:AddChild>
        </mx:State>
    </mx:states>
    <mx:VBox id="vbox">
            <mx:Button label="Click" click="currentState='newCheckbox'" />
            <mx:Button label="Click" click="currentState='newTextArea'" />
    </mx:VBox>
</mx:Application>


Now this exact same example refactored to use the new Flex 4 in-line state syntax:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="library:ns.adobe.com/flex/halo"
   xmlns:m="http://ns.adobe.com/mxml/2009" layout="absolute">
    <m:states>
        <m:State name="default"/>
        <m:State name="newCheckbox"/>
        <m:State name="newTextArea"/>
    </m:states>
    <mx:VBox>
        <mx:Button label="Click" click="currentState='newCheckbox'" />
        <mx:Button label="Click" click="currentState='newTextArea'" />
        <mx:CheckBox id="checkbox" label="Checkbox" includeIn="newCheckbox, newTextArea"/>
        <mx:TextArea id="textarea" includeIn="newTextArea"/>
    </mx:VBox>
</mx:Application>


Additionally you can define state specific properties and event handlers using this in-line syntax:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="library:ns.adobe.com/flex/halo"
   xmlns:m="http://ns.adobe.com/mxml/2009" layout="absolute">
    <m:states>
        <m:State name="disabledState"/>
        <m:State name="enabledState"/>
    </m:states>
    <mx:HBox>
        <mx:Button id="button" label="Enable" label.enabledState="Disable"
            click="currentState='enabled'"
            click.enabledState="currentState=''" />
        <mx:TextInput enabled="false" enabled.enabledState="true"
             text="example text" />
    </mx:HBox>
</mx:Application>


For more information on the new in line state syntax please see the
Enhanced States Syntax – Functional and Design Specification


Primitive Graphic Shape Components

The Flex 4 FXG, code named Gumbo, provides new primitive graphic components including rectangles, ellipses, lines, and Path.  This is primarily in support of the new Flash Catalyst tool-set that intended to better separate the designer goals from the programming implementation.  Nevertheless, these primitive graphic components are a welcome addition that will help make creating simple onscreen graphic and composite controls much easier.

More information here:
http://livedocs.adobe.com/flex/gumbo/html/WS145DAB0B-A958-423f-8A01-12B679BA0CC7.html


Text Engine (requires Flash Player 10)

Finally the major new feature I have been waiting for is the new FP10 text engine support.  Flex 4 text based components make use of the new text engine provided by Flash Payer v10.  I have not  had a chance yet to explore this new feature-set, so I will be digging into it soon and posting more info.

Terry demoed the New York Times Reader Adobe Air application and shows some of the new impressive capabilities of the new text engine.

I am more interested in the right-to-left (RTL) support added to properly support internationalized applications in RTL languages such as Hebrew and Arabic.

For those stuck in Flex 3, I know there is a Text Layout Framework provided to make use of the new Adove Flash Player 10 text engine.  Here are a couple of reference documents on this framework:


Categories: Adobe Flex

Special Event!! Adobe CF & Flex User Group Tour, hosted by the Alamo Area CFUG

June 14th, 2009 No comments

Mark your calendars for June 23rd!

The Adobe CF & Flex User Group Tour hits San Antonio’s Alamo Area CFUG

Tour Event: San Antonio Adobe CF & Flex User Group Tour Stop, hosted by the Alamo Area CFUG
Date & Time: June 23, 2009 from 6:30pm – 8:30pm
Address: 13330 Kyle Seale Pkwy San Antonio, TX 78249  google map





Come join the Alamo Area ColdFusion User Group at the Igo Branch of the San Antonio Public Library for a special event. Adobe’s Terry Ryan (Platform Evangelist) will be showing us the next version of ColdFusion, the new ColdFusion IDE, ColdFusion Builder, the Flex Framework and some great things to come in the next product releases.  He’ll also show us the new features and products focused around the Flash Platform including Flash Catalyst (formerly known as Thermo) and Flash Builder (formerly known as Flex Builder).  We have $2100 software to give away as well as other great prizes.  As always, we’ll have food, drinks lots of fun.


RSVP  here:   http://www.meetup.com/AlamoCFUG/calendar/10633189/

More Info:  http://groups.adobe.com/posts/8ba40b304c


Categories: Adobe Flex