Monthly Archives: December 2004

DataProvider Event Magic

DataProvider is really cool but there are some events you need to know to make them much easier to work with.&

DataProvider is a Mix-in class that adds methods and events to the Array Class when a V2 list-based component is added into your application. There is no DataProvider class, per say, it just enhances Array to provide the methods and events needed to support a common data model for V2 components.

When you set the ‘dataProvider’ property in a component, the component subscribes to the events of the data array. This allows updates to the array data to cascade back to the component and update the view.

myArray = []

myArray[0] = {label:0}

myArray[1] = {label:1}

myArray[2] = {label:2}

myArray[3] = {label:3}

myList.dataProvider = myArray

The problems start when you modify the ‘myArray’ directly without going through the component or using the DataProvider methods. As follows:

myArray[4] = {label:4} //this will not show in the component!

When you use the component methods addItem, addItems, etc, they fire events within the dataProvider to update the view in the component. If you edit them directly via array methods, the component doesn’t know the model has changed and this can leave the view of the component in a less than ‘finished’ state.

What we can do is fire an event directly when we make modifications to the dataProvider. This allows you to edit the array using all methods of Array and DataProvider and sync up the component view. Here is the magic:

myArray.dispatchEvent( {type:”modelChanged”, eventName:”redraw”} )

Essentially the ‘modelChanged’ event, fires methods within the subscribed components directly. The cool part is that you do not need to know about the component instance and you can use the Array methods without breaking the component view.

Take a deeper look at for more on this event magic, there are lots of uses of the “modelChanged” event that are worth a look.


Ted ;)

FlashStallerWin – 100% Free Flash Exe Builder

I wrote an installer to create a single file executables containing the Flash Player and external app files. Using the LZMA compression, the exe is 492Kb.

What you need:

NSIS from Nullsoft


Simply compile the ‘setup.nsi’ file to create your executable. Any file within the ‘installFiles’ directory will be added into the installer.


Ted ;)

2000 installs of XTreeM in 50 days

I have received a ton of feedback on XTreeM and a new version should arrive just after the new year. Also XTreeM has received some external shareware reviews and is now listed at and &

Here are the listings:

SoftPedia Certification

CNet Asia

XTreeM has some great changes coming after the new year. Arul has agreed to add his XML Highlighter into XTreeM. I am working on adding direct editing of XML, major layout changes for usability, XML caching, and documentation.

More to come.

Ted ;)

Python 101

I am a big fan of the Python language. Having worked with it for years, I keep finding that aspects of the language are well suited to solving real world programming problems. Here is a brief tutorial on Python.&

Download Python

Code Examples

Hello World Example:

print( ‘Hello Python World’ )

Variable based Hello World Example:

h = ‘Hello’

w = ‘World’

p = ‘Python’

print ( h + ‘ ‘ + p + ‘ ‘ w )

Python has a interactive command line that ships with all versions. It allows you to type programs into the interpreter line by line and get instant feedback to test assumptions on small parts of programs. As you type lines they execute when you press return.

Read and Write to a file:

file = open(‘foo2.txt’, ‘w’)

file.write(“testing, testing\n”)


print open(‘foo2.txt’).read()

Download a Web Page and print it:

import urllib

pageFileObject = urllib.urlopen(‘’)

print( )

There are thousands of libraries for Python and all of them are imported via the import command. Actually any application you write can be imported via import allowing you to reuse code seamlessly. Once you import a library, you can use the class/code objects as needed in your application. Take some time to explore the Python installation especially /lib contains source (.py) and bytecode (.pyc) for all of Python’s base types and extended types. If you open .py files in a text editor you can quickly see what the library does. In the above example I imported urllib, which is actually /lib/ and used the open method to retrieve a web page into a file object. Then using read(), it returned the text of the file to the print method.

One aspect of Python is very confusing to anyone new to Python. Python treats some whitespace characters as valid code to denote code blocks. When you write blocks all code of equal indentation is within the block.

If block example:

a = True

if a:

      print( ‘a is True’ )

      print( ‘Still within the if block’ )


      print( ‘a is False’ )

      print( ‘Still within the else block’ )

That seems weird for many (Chafic and Darron included!) as it removes most of the {} and ; within code, in Python they just are not needed. The interesting thing is that Python code is very readable because all developers must format software in according to block indentation standard. Python just enforces you to do what you should be doing already.

I wish you all the best on your Python expedition. Should you have any questions you know where to reach me ( ted -AT- powersdk -DOT- com ).

Python Official Tutorial


ted ;)

XML Resolver 1.05 (F7 compatibility)

Bob Roswell reported an error to me regarding XML Resolver. I took a look and sure enough the library wasn’t F7 compatible. Here is a new compatible version.&

XML Resolver extends the XML object to support name based editing of XML Nodes. It makes it really easy to edit and read XML documents. Best part is that there is no reparsing of the XML document, ever! Resolver uses __resolve to virtually remap the path resolution of the XML Object. When you request a name based path, the __resolve function kicks in and returns the correct item if it exists. If you are setting the value, it will extend the XML object in place.

Download XML RESOLVER 1.05

Here is an example of its use:

PRE {font : normal normal normal 12 “Courier New”, Courier, Arial;;}

x = new XML("blahHello World")

trace(x.a) //return XMLnode
trace(x.a.t[2]) //return XMLNode
trace(x.a.t[2].attribute.age) //return attribute value
trace(x.a._value) //return XMLNode
trace(x.a.t[1]._value) //return TextNode Value
trace(x.a.t[2].attribute) //return Attribute array
trace(x.a._node) //return XMLNode
trace(x.a.t[1]._node) //return XMLNode

x.a._value = "blah22" //add/edit TextNode Value
x.a.t[1]._value = "Hellllo World" //add/edit TextNode Value
x.a.t[2]._value = "222 World" //add/edit TextNode Value
x.a.t[0] = "fido" //add/edit attribute Value
x.a.t[2]._attr.age = 34 //add/edit Attribute Value
x.a._node = "" //add Node
x.a.t[0]._node = "" //add Node

(Credit to Arul for AS color!)

The library was written for Flash 5 originally and migrated to Flash 6 in 2003. There were 2 errors in the library that were fixed in this release.

1. Case sensitivity is now correct. XMLNODE is now XMLNode.

2. The AS2 compiler doesn’t like you modifying classes at runtime and doesn’t allow using ‘prototype’ or ‘__proto__’ in code compiled for AS2. There is a hack for this that works really well, simply evaluate the keywords as strings and everything works just fine.

XMLNode["prototype"].__resolve = function(){}

XMLNode["prototype"]["__proto__"] = XMLNodeSubClass["prototype"]

If you find any bugs just drop me an email and I will see what I can do. Thank Bob for reporting the error, glad I could help.


Ted ;)