Adam 1, oBIX None

June 2nd, 2008 · 3 Comments

After a hard day’s work on the oBIX to Flash project I blogged about yesterday, I am happy to report that progress is moving fast.  The module (currently called FloBIX) is able to parse oBIX and convert it into a collection of ActionScript 3 objects – usable in Flex 3 or Flash CS3.  It currently supports the following oBIX primitive types: Abstime, Bool, Icon, Int, Obj, Real, Ref, Str and Uri.   These primitives support all documented attributes.  The next step is finishing up Reltime and dealing with Contracts and Ops.  

All objects other than the main class (FObix) are subclasses of an abstract object called FAbstractElement.  This class supports all common attributes in oBIX and is extended for the various elements (or objects as they are referred to in the oBIX specification).

The FIcon class extends Sprite and is able to be called on by your ActionScript code to actually display the icon file that oBIX points you to – the loading of the graphic file is taken care of automatically by the FIcon class based on the URI given in the icon attribute.  Example: this.content = obix.Root.Children.SomeControlPoint.Icon; will set a Sprite or MovieClip’s content to the icon property of an oBIX object.

Like most Flash objects, FloBIX is completely event driven.  A custom event wrapper has been written for all FloBIX asynchronous calls which can be handled just like any other event in ActionScript.

The main class accepts a string of XML data or a URI to an oBIX feed and then parses the XML into a collection of Flash objects.  Example: obix.setXMLByURI(new URLRequest(“http://192.168.1.255/obix/Device”));  By utilizing the URLRequest object you can specify other data such as POST variables – which may be required for authorization on some devices/servers.

An ArrayCollection is being used currently, however I intend to write a custom class for collection which will allow for querying of children by URI, name, etc.  In lieu of this custom class, helper methods are being used for this type of access i.e. methods like getChildByName(), getChildByURI(), etc.

I am starting to get excited about implementing this library in an actual project when it’s completed, but I’ve had about all the oBIX I can stand for one night!

Tags: ActionScript · Flash · Flex · oBIX · Work · xml