Chapter 09
Recursive Approach
Goals

This chapter highlights improved programming concepts. It focuses on event-driven code and recursion. We will consider these in the abstract, then as used in ActionScript and as applied to the example code we have been developing. We will also try a few approaches to text filtering for whitespace removal, and we will face some problems of extracting data from XML.

In doing so we will build a graphic browser for XML - one that functions as an interactive probe into the data structure. This extends earlier work we did on a text-based XML tracer. We will create event-driven callback routines and recursive tree-walkers.

Starting

Looking back at our general XML display code, we see that the problems with our current design are glaring. It is procedural in all the worst ways. It executes sequentially rather than on events, and it elaborates itself through three handcoded levels of hierarchy rather than through infinite depths. XML does not follow such a limit. So we will go again into the code and rebuild it from the inside out.