Prev | Current Page 778 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

js??? > < /script >
< /body >
< /html >
There is a reference to a style sheet that is used to obtain the effect illustrated in the figure. The CSS is out
of the scope of this chapter but the illustrated aspect can be reproduced easily using the proper class
and id selectors.
The client and the server scripts share a common piece of code contained in the class ColorsUtil that is
a utility class defined to help the developer to stay DRY. The class has three methods to transform a list
of colors to and from an XML document and to filter a collection of colors using the first letters of their
names.
typedef Color = {
name : String,
hex : String
}
class ColorsUtil
{
public static function fromXml(data : String)
{
var xml = Xml.parse(data);
var colors = new Array();
for(color in xml.firstChild())
colors.push({name : color.get(???name???), hex : color.get(???hex???) });
return colors;
}
public static function toXml(list : Iterable < Color > )
419
Chapter 14: More Interactive Content with JavaScript
{
var xml : Xml = Xml.


Pages:
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790