The life and times creating engaging media experiences.

March 2007

» to Main Page
Flex Quick Starts: More Handling Data

Since my original post on the subject, there are 2 additional tutorials for handling data in the Flex Quick Starts area of the Adobe Flex Development Center.

  • Accessing XML data: ActionScript 3.0 used in Flex 2 leverages the ECMAScript for XML (E4X) specification to make available improved functionality for working with XML data. Because XML is a native data type in Flex, you write XML and assigning it to a variable. The tutorial explains how to access data values and assign data values with XML by using dot notation. Another example illustrates how to assemble and transform XML objects using the prependChild, appendChild, insertChildBefore, and insertChildAfter methods. (There was also a note about a known issue in Flex: when deleting an item from the data provider of a list control, the selectedIndex value is set to an incorrect value.) Another example illustrated various ways to query XML data right within ActionScript.
  • Loading external data with HTTPService: This tutorial provides an example of using the HTTPService to obtain external data via HTTP calls. Data can be obtained from other domains, but they have to employ the proper use of a crossdomain.xml file. In this particular example, the resultFormat was set to "e4x", and the namespace was set to the atom namespace.
ASP.NET Scheduled Processing

If you have ASP code that you want to run on a scheduled basis, there is a way to do so that avoids you having to compile your code into a Console Application (or use a Console Application to call your main code in a Web Service on a periodic basis) and run it as a Scheduled Task in Windows.

The technique described below leverages the callback feature of ASP.NET cache expiration to trigger the running of your desired code on a periodic basis. One key advantage of using this technique is that you have a tighter code base (without having to branch out into Console Application) that is easier to maintain and deploy. Another main advantage is that you can implement data-driven (robust and easy to maintain) scheduling rules instead of having your scheduling logic embedded within a Windows Scheduled Task (which has its own set of administrative burdens).

The Web Page (A) with frequent visitor traffic calls a Web Service Procedure (B) every time the web page loads. It is best if you use a web page that gets a page view approximately every minute. If the web page you use does not get frequent visitor traffic, then you will not be able to run your scheduled code with precise timing. [sample code]

The Web Service Cache Procedure (B) stores a dummy value in cache for a specified time interval and defines a Delegate Procedure (C) to be called upon cache expiration. This code first checks for the existence of the dummy value in cache; if it does not exist, then the value is inserted into cache and set to expire in an amount of time that represents the periodicity with which you want your scheduled code to run. [sample code]

The Delegate Procedure (C) calls a Web Service Procedure (D) to establish an HTTPContext, which is essential for proper subsequent code execution. It is important to appropriately set the timeout property of this web service call; the default value of 90 seconds may not be enough time for your scheduled code to finish running. [sample code]

The Web Service Run Procedure (D) automatically establishes HTTPContext and calls a Scheduled Procedure (E) that contains the main code that should be run. [sample code]

The Scheduled Procedure (E) executes the code that is to be run automatically at periodic intervals. Now that you have code that fires on a routine basis, you can wrap this code within custom processing logic to implement complex rules that dictate valid processing times. [sample code]

Flex Skinning Napkin Example

Eylon put together a cool example of Flex's skinning capabilities, illustrating why there's no reason to rely just on the default look and feel when publishing a Flex application. Eylon's napkin skin example is presented in 3 stages (1 | 2 | 3) that explain the various skinning techniques employed. I found this information from Sho Kuwamoto's blog posting.

Flex Quick Starts: Working With Tree Controls

Since my original post on the subject, there is an additional tutorial for building an advanced user interface with Flex in the Flex Quick Starts area of the Adobe Flex Development Center.

  • Working with Tree controls: Regarding the choice of data provider for a Tree control, if you have well formed XML and plan on manipulating the data as XML, you should use an XMLListCollection object as the data provider; if you have object data that changes dynamically, you should use an ArrayCollection object as the data provider. In either case, you should always use collection objects (XMLListCollection instead of XMLList and ArrayCollection instead of Array). Examples are provided in this tutorial to explain how to a) add / remove leaf nodes and branch nodes at run time, b) open the tree to a specific node, c) read an XML document with multiple node names, d) keep a Tree control expanded when its data provider is updated with new data, and e) dragging and dropping to and from a Tree control.
My Friend Kevin The Artist

A few years ago, my longtime friend Kevin Peskin began using his creative and artistic talents toward producing unique works of art. His paintings are best described by Kevin himself:

These surreal landscapes give the viewer the freedom to let the mind wander to a place unknown. The complexity of light, color and texture creates a visual experience that allows the imagination to run free. My paintings are a journey of the heart, mind and moods with the appearance of unfamiliar reality and solitude...

Kevin has artwork for sale and produces commissioned pieces as well. Enjoy taking a look at his website, The Artwork of Kevin Peskin.