A Tip on using XML Class methods on XMLList Objects.

May 14, 2009

For using the XML Class methods with an XMLList Object containing one or more XML Objects you have to iterate through the XMLList Collection and apply the XML Class methods to each XML Object in the Collection.

For example use the for each.. in statement to iterate through the XMLList Collection and access the individual XML Objects and apply the required XML Class methods to the individual XML Objects.


Suppose i have an XMLList Like below











then i would iterate this XMLList like below,

for each(var xml:XML in resultXMLList)


trace(“ ”+xml);//now apply XML Class methods to this XML Object.


[Here resultXMLList is my XMLList]

Observe the output now,it will print out the individual XML’s.Enjoy the post.

Tip on Formatting dates with the DateField Control in Flex.

May 5, 2009

We can specify a function to format the date displayed in the text field using labelFunction property of the DateField control. Function will take date and returns the string representation of the date, and in the function we can use the DateFormatter Class to format the date to our needs.

Now to parse the entered date as text we specify a parse function using the parseFunction property of the DateField control. Function takes two arguments, entered text and the formatString and returns a date object typically performing the reverse of the label function. DateField uses a default parse function DateField.stringToDate, but we can specify a custom one. If you don’t want to edit the DateField control then simply specify null to the property.


For example to represent dates in the editable DateField control in DD MMM YY [10 Feb 09] format, we make use of lableFunction, parseFunction properties of the DateField Control.


Using two DateFormatters

<mx:DateFormatter id=”dtf1″ formatString=”DD MMM YY”/>
<mx:DateFormatter id=”dtf2″ formatString=”DD/MM/YY”/>

//the label function
Read the rest of this entry »