Adobe Flex 3 Help

Creating agents

You create an agent as a SWC file and link it into the Flex application by using the include-libraries compiler option. You can link multiple agents in any number of SWC files to the same Flex application. However, to use multiple agents at the same time, you must use the same environment configuration files for all agents.

The general process for creating a custom agent is:

  • Mark the agent class as a mixin; this triggers a call to a static init() method from the SystemManager class on application start up.
  • Get a reference to the AutomationManager class.
  • Add event listeners for the APPLICATION_COMPLETE and RECORD events.
  • Load the environment information (Flex metadata that describes the objects and operations of the Flex application). Environment information can be an XML file, as the samples use, or it can be in some other data format.
  • Define a static init() method that creates an instance of the agent.
  • Define a method that handles RECORD events. In that method, you can access:
    • Automation details such as the automation name
    • User information such as the FlexSession object (through a RemoteObject)
    • The event that triggered the RECORD event
    • The target object and its properties that triggered the RECORD event

    The RECORD event handler in the agent gets an AutomationRecordEvent whose target is the object on which recording happened. The automationManager.createID() method converts the object to a string that can be recorded on the screen. Some tools may require the entire automation hierarchy that needs to be generated in this method.

You also use the custom agent class to enable and disable recording of automation events.

For more information on creating a custom agent, see Creating a recording agent.