Asynchronous loading of localized data files, or how to check if a file exists without actually reading it
At a first glance, reading data files in Flex is easy. But sometimes things which seem simple (and should be simple!) actually prove to be tricky... I would like to share my experience in this area, hoping it may be of some help to others.
The problem to solve
Let's start with a description of a set of development requirements:
The above requirements look quite analogous to those of the Flex mechanism for dealing with resource bundles for the localization of Strings in ActionScript or MXML, for which Flex provides already everything you need (see Using resources in Flex documentation). Furthermore, we do want a similar policy for loading localized data files as the one Flex uses for loading resource bundles for a given locale chain:
The Flex application uses the list of locales in the localeChain property (of ResourceManager) to determine precedence when getting values from resource bundles. If a value does not exist in the first locale in the list, the Flex application looks for that value in the next locale in the list, and so on. (citation from Flex documentation)
But this resource bundle mechanism does not apply (at least not directly) to the loading of data files. So let's try to implement it by our own. At a first glance, it should be a piece of cake:
Fine. But for our purpose we need to iterate over URLs with relative parts such "dat
So, these APIs offer several means to detect either a loading failure, or a loading success. Can we just rely on just one of them in all cases? Testing in various cases brought a negative answer... The behavior of these APIs varies from one testing platform to another, for reasons such as design or implementation choices or bugs in Flex/Flash, variety of behaviors of browsers and webservers. All in one, I had to use a combination of the means mentioned above to be able to put in place an utility function which works in all the use cases that we tested.
Examples of behaviors which are browser-dependent:
The sample application uses the utility function Asyn
Here is how the sample application looks like:
In this example, the log shows the execution traces corresponding to the loading in Internet Explorer 9 of a data file which is available for the second locale in the locale chain, but not for the first locale. The important point is that, as you can see, the execution sequence includes, for Internet Explorer (at least 8 and 9), an event of type "open" even for a file which does not exist! This does not hold for Chrome or Firefox, but it means we can't blindly consider that a file exists just because we received an "open" event! As a matter of fact, the loading goes differently depending on web browsers, and potentially Flex and Flash versions (see the Adobe bug mentioned above), and web servers (which may react differently to requests for unavailable resources). The utility aims to cope with a variety of behaviors while detecting as soon as possible whether a file exists or not for a given locale. There is no theoretic guarantee that it works optimally in all possible cases, but it has been successfully tested on all the combinations of OS and browser supported by Flash Player 10.3 (recent versions of Chrome, Firefox, Internet Explorer, Opera, Safari, on Windows, Linux, and Mac OSX systems).
You can run the sample application by clicking here. To view the source code, right-click anywhere in the application and press "View Source".
The only new module of Elixir 3.5 is the microcharting module (a.k.a. "Sparklines").
According to the user manual available online:
Since microcharts are based on the Spark architecture, let's see how to modify the skin of the component to:
To display the last value, we use host
Everything else is styling. In this example, the chart (rendered by the <ibm
Here is the result:
Click here to download the source code.
Comments (3) Visits (3619)
If you are like me used to read online documentations more often than the ones installed on your disk, I have a good news for you. Indeed the IBM ILOG Elixir Enterprise 3.5 documentation can now be found online at the following url: http
IBM ILOG Elixir® Enterprise extends the Adobe® Flex® and Adobe AIR™ platforms by adding user interface controls for more intuitive, interactive displays. ILOG Elixir Enterprise provides a full spectrum of advanced graphical displays for the most demanding line-of-business applications.
New graph layout algorithm: Circular layout
Circular Layout is designed for graphs representing interconnected ring and/or star network topologies, as in the following example:
Improved layout of nested graphs thanks to a new mode of Hierarchical Layout
In the previous release, it was necessary to use a combination of "node layout" and "link layout" in
order to lay out a nested graph including intergraph links (links that connect nodes from different subgraphs).
In Elixir 3.5, Hierarchical layout has been improved with a recursive mode such that it can handle by itself an
entire nested graph. This simplifies user's task for configuring the layout: no link layout is needed anymore.
Moreover, it improves the quality of the layout, because instead of optimizing the layout locally for each
individual subgraph the algorithm now performs a global optimization taking into account the entire nested
hierarchy. The quality improvement consists in a reduced number of link crossings and a more regular layout
of the links. The following screenshots illustrate this benefit by comparing the result for the same nested
graph with, and without this new feature:
Nested graph laid out by Hierarchical Layout in recursive mode (new in Elixir Enterprise 3.5)
Same nested graph laid out by Hierarchical Layout in non-recursive mode (old mode in Elixir Enterprise 3.0)
The new recursive mode is enabled by default. If necessary, it can be disabled by setting Hier
Improved self-link and multi-link layout
A new link layout algorithm has been added: Basi
Multi-links and self-links laid out laid out by the new Basi
Other new features
The Elixir team hopes you will enjoy these new features! As usually, feel free to ask any questions.
Comments (2) Visits (5663)
In IBM ILOG Elixir 3.5, we had the opportunity to re-write the calendar as spark component. The component is compatible with Flex SDK 4.5.x.
The keyword for this component is "flexibility", you will understand why in the next sections.
Here is an non exhaustive list of new or improved features:
First of all, the calendar is a real spark component which means that you can customize any pixel of the component.
At the contrary of the previous version which was a sort of black box, you have access to the internals of the calendar, its sub components, how they are placed, how they are rendered etc.
By accessing the Calendar skins you can:
Here are three different skins applied on the same component instance.
The default skin (click on image to enlarge it)
The spark calendar provides sub components (row header, column header, grid, data groups, layouts etc.) and base classes and building bricks to create your own skins.
Multiple calendar display in column view
In the previous versions, the color of the item renderers was used to differentiate two items that are belonging two different calendar.
In addition to colors, in order to easily compare items from two different calendars, the new component can, for each column representing a day, display a sub column per calendar.
When time is selected in sub columns, you can easily determine the associated calendar, for example to create a task on the selected calendar.
Type of view and time range are not correlated
The calendar's core job is to display events in time through different views. In MX calendar, the kind of view is determined by the duration of the queried time range. This is not the case anymore, now you specifies the time range to display and the display mode: columns or grid.
For example this kind of view were not possible in previous versions:
Time range definition
To set the time range, you can:
Item / renderer association
Before the kind of renderer (vertical, bar, horizontal or label) was hard-coded according to event duration.
Now you can specify the kind of renderer to use for each item using a simple custom function. It is very easy and very powerful.
Here are some examples where the default behavior is overridden:
Here are some screen shots of usage of the renderer kind custom function:
The Calendar components now has the ability to filter out some days of week.
Here are some example of usage of day filtering:
Time of day filtering
Another feature often asked is the ability to choose the first and last hour displayed in the view.
In grid display mode, it only applies on horizontal renderers and not labels.
Only the 8am to 6pm part of the day is displayed: the left side of a cell is 8am and the right side is 6pm.
Minimal sizes supported
If an event is very short is may not be readable. If readability is more important for you than exact time projection on the screen, the layout is now supporting a minimal height or width.
With a minimal height, the event is visible but its end is not correctly projected so the label must include end time.
New grid display mode layout properties
In grid display mode, it is now possible to configure the layout to make the horizontal renderer to fill cells.
The horizontal renderer can now overlap each other like in columns display mode.
The definition of working and non working periods is now delegated to dedicated object.
This work calendar allows to:
As this work calendar is also used in the Gantt chart components (resource chart and task chart), it allows a seamless integration of the calendar component in an application using these two components.
New animation engine
The new architecture allows to create new animations:
The sole transition that is not animated is from one display mode to another.
Comments (6) Visits (4458)
Earlier this week we announced the release of Elixir Enterprise version 3.5. Some highlights of this new release include:
If you're interested in checking out the new version, the 90-day trial of Elixir Enterprise will be updated next with the latest enhancements.
In this newly recorded presentation Exploring choices for desktop and mobile RIA applications, learn the pros and cons of these three technologies: HTML 5 and Dojo, Adobe Flex, and Microsoft Silverlight. This recorded presentation has several demonstrations and provides insight about which technology is best for your RIA or project.
The next time you visit the Elixir Enterprise pages on ibm.com you may see a survey window appear. If you are interested in providing us some feedback, please click Yes. We are looking for your feedback to help improve the pages.
The survey should not take more than 5 minutes to complete. Head on over to the Elixir Enterprise page if you're interested in completing the survey.
[If you previously said No but are now interested, clear your cookies and the survey should appear.]