Get the Flex Label Text

Add another function to the Action Script file that allows us to get the text of the Flex label component.

You can copy this code from this page or download the source file here.


/**
 * Get the text of the "TestFlexLabel" label
 * @return     the value of the label text attribute, or null if an exception occurred
 */
private function getLabelText():String {
  var label:Label, retval:String = null, id:String="TestFlexLabel"; 
  try {
    label = Label(getElementById(id));
    retval = label.text;
  }
  catch(e:Error) {
  }
  return retval;
}