You are viewing the Articles in the News Category

Flex 2.0 Generic Portal Application

I built a generic, configurable portal application awhile back which I have added to my portfolio site. I even added a background image of myself acting like a nut which has a filter effect applied to it based on the position of the mouse cursor.

The Flex 2 Portal is a simple application that is intended to serve as a central location for launching multiple applications. It works great with Firefox as each application will load in a new tab in the same browser, allowing for all of the applications to run without appearing to be disjointed. You can also just simply use it as a portal for launching other websites.

You can view the Flex 2 portal application by clicking the image below. You can also right click and select ‘view source’ from the context menu to view the source code.

Portal

AS3 PHP LoginService API

This morning I wrote a quick API which allows you to easily invoke a PHP script from Flex 2, run a query on a MySQL database for authentication, and pass the results of the query back to the Flex client. The API consists of a simple login value object and a QueryService that calls an accompanying PHP script. The PHP script then runs a query based on the login value object passed in the query string as name value pairs.

The AS3 PHP LoginService API is intended to simply serve as a base class only. It is to be used as a starting point from which you can create a real world application based on sub-classing the QueryService to apply an MD5 encryption algorithm and so forth.

You can check out the example, accompanying ASDoc and source code as well as a Cairngorm 2.0 implementation which I created.

AS3 Iterator Pattern Implementation

The greatest thing about design patterns is that they are typically not much more than an efficient, structured way of doing things that most of us have already been doing for a long time. Design Patterns allow us to simplify common design problems into standard, common named solutions. By implementing common design patterns and best practices we can keep our applications consistant without re-inventing the wheel everytime. They allow us to solve the same problems over and over again in the same way. Design patterns also allow us to write code that is common amongst other developers. This is helpful as it allows other developers who are familiar with these patterns to easily and intuitively work with our code, and vice-versa.

Every Software Developer iterates over objects on a regular basis. That is, every software developer has the need to loop thru an array or traverse an object at some point during the development of an application. This is obviously a basic part of programming so we usually don’t give it much thought. However, once in while it is good to reflect upon the things that have become routine to determine if there is a common solution out there. We often run into situations where we create an API that consists of a collection of objects that a client may want to iterate over. In order to provide the required functionality we have to define an interface in which the client can iterate over our collection without exposing the collections underlying implementation. This is where the Iterator Pattern comes in handy. Iterators are used to access the elements of an aggregate object sequentially without exposing its underlying representation. Iterators are intended to remove traversal responsibility out of the aggregate object.

I have created an AS3 Iterator API which consists of an interface (IIterator) that defines the methods which implement the Iterator Pattern. The IIterator interface is implemented by an internal base class (Iterator) which is sub classed by concrete iterator implementations (ArrayIterator, ArrayCollectionIterator and ObjectIterator). I have also provided an IteratorFactory which handles instantiating Iterator sub-classes so that they may be referenced by the same iterator instance.

You can view the example and ASDoc as well as download the swc for the AS3 Iterator API.

AS3 Custom Tween API v0.9.3

After numerous requests I finally found the time to update my AS3 Custom Tween API to version 0.9.3.

In case you are not familiar with the Tween API it is a simple API which enables any object on the display list to have a tween effect applied to a property of the object. You can view the the original Tween API post here.

Version 0.9.3 has had the following additions implemented:

  1. Tween Interval has been increased to 30fps as oppossed to the original 12fps. The original 12fps would run slow unless the framerate of the swf was increased.
  2. A callback function can now be passed in as an optional parameter. The callback function will be invoked once the tween effect has completed.
  3. An optional callback argument of arbitrary length can also be passed in as a parameter of the callback function.
  4. An additional Tween.stop(); method has been added which will allow a Tween instance to be stopped at anytime while the tween effect is executing.
  5. TweenTarget parameter’s type has been changed from DisplayObjectContainer to DisplayObject. Originally I had wrote the Tween API as a simple, application specific API that I thought other developers could use. I have now updated the API so that it is generic and can be applied to any object on the display list.

Download source and view ASDoc.

Keep in mind that this is an unstable beta release, that is, I have not thoroughly tested the API as of this release but it does however meet the requirements that I have been requested. Once testing is completed and all bug fixes are complete I will make one last major build before a final version 1.0 release. So if you happen to find any bugs please feel free to let me know.

AS3 DisplayObjectContainerManager

A co-worker of mine ran into a problem the other day in which he needed to remove a component from it’s parent container and relocate the component to a new container. This type of functionality is pretty common in flex applications so I decided to write a simple utility class to handle relocating display objects from one container to another.

The DisplayObjectContainerManager is a singleton pattern implementation in which there is a single instance created which handles display object relocation from within the display list. DisplayObjectContainerManager allows a component to easily be removed from it’s parent container and relocated to a seperate container while retaining it’s current state.

You can view a basic usage example here or view the ASDoc for the DisplayObjectContainerManager here.

AS3 WSDLURIProxy Class

Many times when you are developing Flex 2.0 Applications utilizing Flex 2 Data Services you will most likely be consuming a web service in various components through out your application.

For instance: Imagine an application in which there are three different view states in the application and you have implemented a ViewStack to handle the different states. Within the ViewStack there are 3 seperate custom components. Each custom component contains a datagrid which displays data retrieved from a Web Service via a mx:WebService tag. In the Web Service tag you set the wsdl property to a specific Endpoint URI.

The only problem is that if you are working in a development enviroment and your application moves to production you will most likely need to change the wsdl destination in all of your components. This approach is fine and is also very common in simple Flex Applications which consume a webservice as a data source. A more efficient way of setting the Endpoint URI is by adding channels and destinations to the services-config.xml file located in WEB-INF\flex that the Web Service tags can point to. The WSDLProxy class adds the same functionality but in ActionScript, therefore there is no need to modify the services-config.xml.

How the WSDLURIProxy works is very simple. You set a static constant of type String to the URI of the Web Service endpoint. Next all you need to do is import the WSDLURIProxy in all of your components and set the ‘wsdl’ property in all tags to: wsdl=”{WSDLURIProxy.getEndpointURI()}”. and that’s it.

Now once your application is pushed form development to production if the Endpoint URI needs to change you can simply change the URI in the WSDLURIProxy and all of your Web Service tags will reflect the changes. Very Simple. If your working on a simple application and not using Cairngorm then this is a very useful utility.
Below I have provided links to the source code as well as complete WSDLURIProxy ASDocs.

WSDLURIProxy.as

ASDOC