Create Combined Java/Flex project in Flex Builder

April 23, 2008 – 6:37 am

One of the new features in Flex Builder 3 is that you can create a combined Java/Flex project. This feature was added to help developers who code on both server side and client side parts for a project. Also it really helps development by keeping all code together for a specific project and also there is no need for multiple IDEs, like Eclipse + Flex Builder or NetBeans + Flex Builder.

We will create not only a combined Java/Flex project but a LCDS (LiveCycle Data Services) enabled project. Prerequisite for this would be an already installed server (we will go with Tomcat) that you will need to use when creating an LCDS project.

First of all you will need the Web Tools Platform (WTP) plugin installed. To install it go to Help > Software Updates > Find and Install, select “Search for new features to install” and click Next. Click on “New Remote Site”, insert a name for the site (ex. WTP) and in the URL input insert “http://download.eclipse.org/webtools/updates/”. Click on and the new remote site should be listed on the “Sites to be included in search”. Select the site and click Finish. The list of site mirrors will appear, select one of them and click OK. After the search is complete select all features to be installed. You should have something like this:

Read the rest of this entry »


Sending extra data in Java Exceptions to Flex Clients

April 22, 2008 – 7:05 am

When building Java services there is always need for handling exceptions thrown by all kind of sources. Wether those are ConstraintViolationException thrown by wrong database queries, NullPointerException thrown by wrong data manipulations or any other exceptions, all of them should end up handled in the Flex application calling the services.
One wrong usage of data transfer between client and backend services is when no matter what happens on the services, all exeptions are handled on the service and the client is basically listening only for the result method. Lets take a user management service for example. One method should be registerUser. The wrong usage would be that this method returns an generic object, if the register succeeded then it will return a User class (User class is mapped between Flex and Java using [RemoteClass] metadata in Actionscript) and if it fails then it will return an object with some messages and extra data in it. A better alternative to this is by using Java Exceptions, that are anyway handled in the services.

First, a custom exception need to be build, as in this example:

package com.myproject.exceptions;

public class UserServiceException extends Exception
{
    private static final long serialVersionUID = 1L;

    private String customMessage;

    public UserServiceException( String customMessage )
    {
        this.customMessage = customMessage;
    }

    public String getCustomMessage()
    {
        return customMessage;
    }
}

Read the rest of this entry »


Adobe AIR released for Linux

March 31, 2008 – 3:31 am

Adobe AIR becomes truly cross platform with the release of Linux version on Adobe Labs.

AIR 1.0 is available for Windows and Mac OS since last year, the Linux version was delayed due to core Flash Player issues on Linux platform. Starting today Linux developers out there can take the Adobe AIR Alpha version for a ride and also ask questions and share feedback in the Adobe AIR for Linux Labs forum.

Another big announcement is that Adobe is getting more and more involved into the Linux world, now collaborating with the Linux Foundation (LF), a non-profit organization focusing on development of Linux, to ensure that all Adobe RIA technologies are compatible with Linux platform.

For more release notes on Adobe AIR on Linux go here.


Adobe Photoshop Express Released

March 27, 2008 – 2:37 pm

Adobe Photoshop Express was released today as a public beta. Adobe Photoshop Express is a free online Rich Internet Application aiming at storing and editing digital photos, taking the online image editing a step further. You can apply all sorts of cool effects like distort, sketch, tint, hue to you images then store them on albums and publish to the world.

Although its beta version it looks great so far but thing is that its fully available only for US citizens for now. Peoples outside US can go for a test drive. As with all beta products you can also give feedback.

Rumors are that an AIR version will be available soon to take the RIA on the desktop. Cool.

[Update] You can go for an account even if you are outside the US, you just select United States in the Country field (dooh). But keep in mind that the server is in Los Angeles so you might expect some delays when trying all those cool features.


Flex Tip 7: Using Deferred Instantiation

March 26, 2008 – 2:02 pm

When you are using MXML containers and declare the children as MXML tags inside the component, there is a possibility to not load all child components at instantiation, possibility known as “deferred instantiation”. That is, the instantiation is deferred by an amount of time depending on creationPolicy property of Container class. This is the property that sets the rules in creation of child components:

- a creationPolicy of ContainerCreationPolicy.AUTO means that the container delays creating some or all descendants until they are needed. This policy produces the best startup time because fewer UIComponents are created initially.

- a creationPolicy of ContainerCreationPolicy.QUEUED means that the container is added to a creation queue rather than being immediately instantiated and drawn. When the application processes the queued container, it creates the children of the container and then waits until the children have been created before advancing to the next container in the creation queue.

- a creationPolicy of ContainerCreationPolicy.NONE means that the container creates none of its children. In that case, it is the responsibility of the MXML author to create the children by calling the createComponentsFromDescriptors() method.

The version we are interested in is ContainerCreationPolicy.NONE when instantiation of children is let it developer’s hand. So lets go ahead and create a simple component:

Read the rest of this entry »


Adobe Developer Week

March 22, 2008 – 12:53 pm

If you didn’t know, from March 24 to March 28 there is Adobe Developer Week, week that consists of 20 events covering all development areas including AIR, Flex, Flash, Mobile, ColdFusion and Dreamweaver. All events will be hosted on Adobe Connect sessions and if you miss the live ones don’t worry, all events will be recorded and available online within 5 business days.

Go here and register for the event you are interested in. I’m registered to the following sessions:

  • Introduction to Adobe Blaze DS
  • Adobe AIR Local Data Storage Options With Emphasis on Using Embedded SQL Databases
  • Flex and Java – Tying the Knot!
  • Flex Data Services
  • AIR Native Drag and Drop
  • Flex Architecture
  • To register you need your Adobe.com membership login and password. If you need to create a membership, or do not remember your login and password, you’ll need to go to Adobe.com membership page.

    Don’t miss it.


    Flex Tip 6: Garbage Collection in Flex

    March 17, 2008 – 7:34 am

    One of the hot-spots in Flash platform is related to memory, how is it distributed inside the runtime environment, memory leaks and of course garbage collection. The way that memory allocation takes place inside Flash is by instantiation, every time a new Object is created, a memory block is created for it. The problem comes when that Object is freed because its block will not always be re-used by the next allocation. The simple “freed” action wont mark it unused, only Garbage Collection will mark it unused, GC that is ONLY triggered by allocations meaning that if there are no instantiations in the application, its memory usage will not change.

    Now how GC works in its deeps depends a lot on how you build your application, if you remove event listeners from deleted objects, if you re-use your already created object instances and so on. Garbage Collection IS NOT PREDICTABLE, it cant say that your application is bullet proof, that is not leaking memory.

    One trick that you can use to force a garbage collection in your Flex application is by using this statement:

    try
    {
          var lc1:LocalConnection = new LocalConnection();
          var lc2:LocalConnection = new LocalConnection();

          lc1.connect( "gcConnection" );
          lc2.connect( "gcConnection" );
    }
    catch (e:Error) {}

    The simple instantiation of LocalConnection will trigger a full garbage collection, a nice solution you can use in your application.
    Even using this doesn’t assures use that you don’t have memory leaks inside the app, it really depends on how you write your code, if you write it with GC in mind.

    As a reassurance in this matter, next releases will have memory diagnostic tools helping you find any memory leaks your app might have. Until then use the tip with LocalConnection and also there can be made automated test sequences in ActionScript that tests the application without human intervention (like faking mouse or keyboard events).


    Flex Tip 5: Using Runtime CSS

    January 24, 2008 – 12:02 pm

    On large scale projects that will be deployed on more than just one location it is a constant need for re-skinning the application. This applies mostly to “embedding” projects, that is projects that will need to be integrated (embedded) into an already done site, with a custom template.

    First solution would be duplicate the project each time a new theme is required. But this will end up in a bad situation where in one instance a bug is spotted and it will have to be fixed in all of them, making the nightmare of on any programmer.

    Second solution adds in scene css, using them as compile-time css. This means that all styles applied to components are stored into an external .css file that is embedded in the application at compile time. But eventually this will be a problem too. On the bug situation mentioned above, using compile time css will end up in compiling the project for each desired theme, one at a time. Not a very good situation either.

    And here is where the fun part begins. Using runtime css you will be able to build and deploy the application once and then change the css files on the server each time you need a different skin. This goes without changing anything in the code and when the bug problem appears it’s just a matter of fixing and uploading the app again.

    Read the rest of this entry »


    Flex Tip 4: Export Release Build (Flex Builder 3)

    January 23, 2008 – 12:16 pm

    If you are creating new project in Flex Builder 3 you will notice that there is no “bin” folder where the .swf, .html and .js files are stored. Instead you get a “bin-debug” folder with the files. This is because Flex Builder 3 threats the project by default as a debug one, running the .swf from “bin-debug” folder.

    When moving a project from Flex Builder 2 to Flex Builder 3 you will get a strange feeling that the size of the .swf for the application gets larger in FB3 that in FB2. Its just a feeling, what FB is doing is compiling the debug version any time you Run or Debug the project.

    To obtain the non-debug version of your application (also knows as release version) you will have to go to Project / Export Release Build. In the popup the “Export to Folder” input is already filled up with “bin-release”, thats where the release version of your project will end up after clicking Finish.

    If you compare the size of both .swf from “bin-debug” and “bin-release” you will see the difference. The one from “bin-release” is the one that should be uploaded to the site or wherever you need it.

    Another small and helpful tip for day-to-day work with Flex.


    Adobe AIR Revolution

    January 22, 2008 – 11:50 am

    Adobe AIR, currently in beta stage, is a new software from Adobe that lets developers using HTML, Ajax, Flash and Flex build and deploy rich internet application on their own desktop. Although AIR finalization is in progress, there are many applications out there built on top of it, showing all the cool capabilities of the software. I will list some of the ones available for the public.

    1. Adobe Media Player




    Read the rest of this entry »


    InsideRIA is out

    January 21, 2008 – 1:31 pm

    Adobe and O’Reilly are on the quest to build up the RIA community and they got a big start with the new site at InsideRIA.com. Browse this site to get information from any domain that it’s involved in building a successful rich internet application, whether that is Design, Development or Standards.
    I’m sure this will become the default RIA community, already involving experts from big companies like Adobe and many other.

    Right now the team includes among others David Tucker, Raymond Camden, Rich Tretola, Andre Charland, Tony MacDonell, Gabor Vida, Jonathan Snook and Andrew Trice. Lets hope they will do great work for all RIA developers out there.


    Flex Tip 3: Using Namespaces

    January 21, 2008 – 12:35 pm

    Namespaces are used in ActionScript 3 to limit the scope of custom methods / properties / constants within classes. The most known namespaces are public, private, protected, internal thought you might know them not as namespaces but as keywords. Besides those you can create your custom namespace to use with your classes. Lets get our hands into an example so you can see it working. On almost every project you will need to handle things differently in testing environment and release environment and this is what we will do.

    Lets first build two namespaces. Namespaces are placed in .as files, .as files that have same name as the namespace. Here is the code for both.

    Read the rest of this entry »


    Flex Tip 2: Template Components

    January 18, 2008 – 11:26 am

    Here’s one of the old problems with the Flex Framework. Templates are not natively supported in Flex but there is one way you can do templates on custom components.
    Lets say we want multiple panels inside the application that look the same, each one has a header with a title and a content area where inner components are placed. One would go ahead and create the header, title and all that is common in a panel each time a new panel is required but this would do a big problem when it comes to code update / change as it will require changing same thing in more places. Here comes the template idea. Instead of creating the header and title each time, why not create one template panel and then use it for all panels that are required.

    Read the rest of this entry »


    Flex Tip 1: Private Class Constructor and Singleton

    January 17, 2008 – 12:27 pm

    Currently, ActionScript doesn’t have support for private class constructors thus any class’s constructor can be accessed. But there are times when you’ll want your class to be instantiated just one time, meaning its constructor called just one time. This relates to the Singleton Pattern where a class is globally accessible in the application by a static function. We’ll get to the Singleton too but first lets see how we manage to have private class constructors.

    See the code below:

    Read the rest of this entry »


    Flex Tips on their way

    January 16, 2008 – 12:50 pm

    As i work all day long with Flex Framework, using and extending it to achieve some great projects i thought of posting tips and tricks to help developers get around issues they encounter. You’ll be seeing pieces of code (once i get the code plugin to work :D ), examples, work arounds but most importantly small tips for day to day job on the Flex Framework.

    So stick around for 1 tip per day, including weekends (yea i’m jammin’ on weekends too), some of them gathered from the net but most of them from the personal experience. Enjoy.


    StreamingBASE solution for Web Conferencing

    January 16, 2008 – 5:51 am




    One of the streaming services available at StreamingBASE is Live, the solution for Web Conferencing, Online Events, Meetings, Courses and much more. Fully scalable and customizable it can be used in almost any successful business running today whether that is IT, Education, Real Estate, Health, Consulting or any other business. Nowadays all corporations doing business over the internet need this kind of software as it cuts the cost of communication, traveling, collaboration, enabling co-workers to get to the subject easily in just 3 easy steps.

    Behind the curtain, the power that drives this software is real time management offered by Flash Media Server and LiveCycle Data Services. First one handles the video feeds from participants, second one is in charge with all real time data exchange in meetings, from chat messages, layout synchronizations, file data exchange, polls, surveys and many more.

    You can try it out in a demo Here but to experience all features and benefits you’ll need to register for a Free Trial Here.

    The services for StreamingBASE Live can be offered both as a hosted subscription and software licensing running behind the firewall. Clients just need to choose what best fits their requirements, software will be configured accordingly and business can start right away.

    Read the rest of this entry »


    Apple MacBook AIR is in town

    January 15, 2008 – 1:10 pm

    No more rumors, what was in the AIR its not a propeller iPod, its the new MackBook AIR.

    “MacBook Air is ultrathin, ultraportable, and ultra unlike anything else. But you don’t lose inches and pounds overnight. It’s the result of rethinking conventions. Of multiple wireless innovations. And of breakthrough design. With MacBook Air, mobile computing suddenly has a new standard.”

    Right now Apple Store gone from “We’ll be back soon” to not responding due to so many visits. Nice.


    Cairngorm vs PureMVC

    January 14, 2008 – 2:40 pm

    As ActionScript gone into a fully fledged object oriented programming language, there are many frameworks out there developed or in development on top of AS 3. Two of the most known are Cairngorm from Adobe Consulting and PureMVC from Futurescale.

    Both of them are build on top of Model-View-Controller architecture but Pure MVC is adding more weight with Facade pattern. I must admit i’ve never used PureMVC, i just read the framework overview and seems that they have some interesting stuffs right there.

    For now i’m sticking with Cairngorm as it is a lightweight easy-to-use framework, real handy and very useful. One example i can give you of how useful is to use these kind of frameworks is actually driven from a mistake. Our StreamingBASE Live project, the platform for web conferencing and events started without a feature specification, that is recording the meetings and events. But the thing that saved us many hours of work adding that feature in the mid project was Cairngorm (that we used right from the start). Now how the meeting works is based entirely on events, cairngorm events. If a message is received, a cairngorm event is dispatched, if the presenter changes the layout in the meeting, a cairngorm event is dispatched on all attendees, and so on and so forth. With this structure, adding record feature was a simple task of storing some cairngorm events with data and re-dispatch those in the same order in the playback. Simple and nice, whew. Good work Cairngorm :)

    Back to our topic here are the diagrams for both frameworks:

    Cairngorm: http://blogs.eyepartner.com/adrian/images/cairngorm2_rpc.gif
    PureMVC: http://blogs.eyepartner.com/adrian/images/pure_mvc.jpg

    If you used both (or at least one) of them, what do you think the ups and downs are ?


    Taking BlazeDS in count for Live

    January 12, 2008 – 11:36 am

    As you probably know, BlazeDS, the server-based Java remoting and web messaging technology from Adobe Labs will be available open-sourced. Now what this technology enables is connecting to back-end data and push data in real time to Adobe® Flex™ and Adobe AIR™ application.

    Right now StreamingBASE solution for web conferencing, online events, training and courses, StreamingBASE Live sits on LiveCycle Data Services Express Edition. The server part is in charge with all commands inside a meeting, chat messaging, layout synchronization and much more.

    Taking in count these two, i think in the near future, Live meeting application will be moved to BlazeDS, allowing us to install it on multiple servers for our clients and in the same time customize (if necessary) it for our needs.

    More info about BlazeDS here, page that is also holding the AMF Specification, that is yet another goodie for developers out there.


    Spell checking for Flex / Flash / AIR

    January 11, 2008 – 6:47 pm

    New cool component from Grant Skinner to spell check you text inside a Flex / AIR application.
    Usability ? Endless, any application that uses a text input / text area would benefit from such a component.Details about the component and some demos here.
    Right now there are some licenses and fees involved. And watch out for you’re text, spell check will make you learn english better :)