GhostWire Studios - Flash/Flex UI Components Development And Consulting Services
Quality User Interface Controls For Flash Application DevelopmentAspireUI Components

Nov 19 2009

uiModel: Using External XML As Data Source During Run-Time

Published by sunny at 5:20 am under Aspire UI,Flash,Tips

The com.ghostwire.ui.data.uiModel class is used to represent a collection of items used as data source for various components in the Aspire UI library. Data-driven components such as the uiComboBox, uiListBox, uiMenu, uiMenuBar, and uiTabView are populated using uiModel objects.

A uiModel object can be populated using an array of data objects (duplicates will be ignored), an array of strings, or an XML object. When populating using XML, the XML can either be embedded with the rest of your application code, or loaded from an external XML file during run-time.


Using Embedded XML
You can declare an XML object in AS3 as follows:

var menuXML:XML = 
<menu>
    <item label="ItemA" />
    <item label="ItemB" enabled="false" />
    <item label="ItemC" >
        <!-- comment: a group of radio items -->
        <item label="ItemCSubMenuItemA" group="RadioGroup1" />
        <item label="ItemCSubMenuItemB" group="RadioGroup1" />
        <item label="ItemCSubMenuItemC" group="RadioGroup1" checked="true" />
    </item>
    <!-- comment: empty item denotes a separator -->
    <item />
    <!-- comment: a check item -->
    <item label="ItemD" checked="false" />
    <item />
    <item label="ItemE" />
</menu>

You can then pass the XML to the constructor when instantiating a uiModel object:

var menuModel:uiModel = new uiModel(menuXML);


Using External XML File
If the XML is saved in an external XML file, you can have the uiModel object call the loadXML() method:

var menuModel:uiModel = new uiModel();
menuModel.loadXML("menu.xml"); // load "menu.xml" and populate the model

This basically means that you can easily externalize the data source of any data-driven component in the Aspire UI library by having its uiModel object call loadXML() during run-time.


Aspire UI Components
Aspire UI is a library of Actionscript 3.0 (AS3) classes for building flexible and lightweight UI elements in Adobe Flash applications. Key features include easy skinning using PNG image files, automatic tab focus ordering, CSS text styles, and layout management. This is a pure AS3 library with no dependency on the Flex framework.

You may experiment with the various features by downloading the trial version.

pixelstats trackingpixel
Share or Bookmark This Post:
  • StumbleUpon
  • email
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Live
  • Yahoo! Buzz
  • Netvibes
  • NewsVine
  • Reddit
  • Slashdot
  • Technorati
  • BlinkList
  • Mixx
  • Diigo
  • Faves
  • Suggest to Techmeme via Twitter
  • Twitter

Other Posts You Might Enjoy:

       

One response so far

One Response to “uiModel: Using External XML As Data Source During Run-Time”

  1. Fruitloopon 20 Nov 2009 at 1:53 pm

    Another great addition to the other brilliant information here. What I like in particular is that a lot of the posts here are unique. A lot of the guides / tips are hard to find anywhere else.

    Again, thanks.
    -F

Trackback URI | Comments RSS

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word