02 October 2008

Curly Braces in Flex Control Properties

Curly braces can make a huge difference in your Flex components' properties. Found out the hard way. I had the following in a custom validator, and wondered why it kept getting passed as a string and not being processed as a function,

<myutil:FileExtensionValidator id="fileNameValidator"
errorMessage="You can only upload JPG, JPEG, GIF, and PNG files."
validExtensions="{new Array('.jpg','.jpeg','.gif','.png')}"
source="{fileName}" property="text" required="true" />

Note the curly braces in validExtensions; without it, no array was being created. Rather, the value was passed as a string. Ted's post helped with figuring out property binding. Duh!

No comments: