Wednesday, June 24, 2009

V is for Validators

The data that a user enters in a user interface control might or might not be appropriate for the application. In Adobe Flex applications, you use a validator to ensure the values in the fields of a form meet certain criteria. For example, you can use a validator to ensure that a user enters a valid phone number value, to ensure that a String value is longer than a set minimum length, or ensure that a ZIP code field contains the correct number of digits.

Included Validators in the mx.validators package:

  • StringValidator - validates input as a string
  • RegExpValidator - validates input against a regular expression
  • NumberValiator - validates input is a number
  • EmailValidator - validates input is in valid email address format
  • Date Validator - validates input is in valid date format
  • ZipCodeValidator - validates input is in zip code format
  • CurrencyValidator - validates input is a valid currency expression
  • PhoneNumberValidator - validates input is in valid phone number format
  • CreditCardValidator - validates input is in valid credit card format
Learn more about Flex Validators at Flex After Dark...

Thursday, June 11, 2009

T is for Timer

The Timer is a utility class in the flash.utils package. A timer's job is to fire off events at specified intervals.

The below ActionScript shows how to create a Timer instance and start it.

   import flash.utils.Timer;
import flash.events.TimerEvent;

// create a timer which fires every second (1000 ms)
var timer:Timer = new Timer( 1000 );

// add a listener to the timer
timer.addEventListener( TimerEvent.TIMER, handleTimerEvent );

// start the timer
timer.start();

Learn more about the ActionScript Timer at Flex After Dark...

Tuesday, June 2, 2009

S is for Styles

You modify the appearance of Flex components through style properties. These properties can define the size of a font used in a Label control, or the background color used in the Tree control.

Styles in Flex are a lot like CSS (which can be helpful), but not exactly the same (which can be confusing). Some style properties also support Cascading Style Sheet (CSS) inheritance. CSS inheritance means that if you set the value of a style property on a parent container, a child of that container inherits the value of the property when your application runs.

Learn more about Styles and Stylesheets in Flex at Flex After Dark...