|
|
||||||
| Ultrashock Tutorials > Flash 8 > XML Portfolio Viewer | ||||||
|
||||||
|
|
XML Portfolio Viewer |
|
||||
pair and triple classesMany of my past applications involved coordinate data. Some applications used cartesian coordinates while others used GIS data (lat,long). A few applications involved naturally paired numeric data that did not represent coordinates. I tend to use specialized pair and triple classes to represent coordinate data. These classes were modeled after the C++ STL (Standard Template Library), although hardcoded for numeric data as Actionscript does not support compile-time templates. Each class has methods for lexicographic comparison, vector norm computation, Euclidean- and great-circle distance computation. For GIS work, I prefer these custom classes to the new Flash 8 Point class. The lexicographic comparisons are a convenient way to determine if one location is southeast of another location, for example. The pair and triple classes also contain methods to create new pair and triple instances as well as copy information from an existing pair or triple into a new pair or triple. There is a format() method to facilitate quick formatting of pair and triple data for printed output. In some applications, numeric data is naturally paired, although the data has nothing to do with coordinates. The portfolio viewer is one such application. Properties such as horizontal buffer distance, vertical buffer distance, and outline buffer distance are collected as an ordered triple. Number of horizontal and vertical thumbnails in the thumbnailer are collected as an ordered pair. This convention is carried over from previous implementations of the viewer. I personally think using the pair and triple classes is overkill for this application. The source code for these classes is included in the event you find them useful in other applications. For more information on the pair and triple classes, including a complete test suite, visit www.2112fx.com/blog/pivot/entry.php?id=6 . |
||||||
©2006 Ultrashock.com - All rights reserved |