XMLConnector.trigger()

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX Professional 2004.

Usage

componentInstance.trigger()

Description

Method; initiates a remote procedure call by the XMLConnector component. This can be either getting or posting to the specified XML file. If the operation is successful, the results of the operation appear in the RPC component's results property.

The trigger() method performs the following steps:

  1. If any data is bound to the params property, the method executes all the bindings to ensure that up-to-date data is available. This also causes data validation to occur.
  2. If the data is not valid and suppressInvalidCalls is set to true, the operation is discontinued.
  3. If the operation continues, the send event is emitted.
  4. The actual remote call is initiated using the connection method indicated (for example, HTTP).

Example

This example retrieves a remote XML file using the XMLConnector by setting the direction property to receive. Drag an XMLConnector component into your library, and enter the following code on Frame 1 of the timeline:

import mx.data.components.XMLConnector;
var xmlListener:Object = new Object();
xmlListener.result = function(evt:Object) {
    trace("results:");
    trace(evt.target.results);
    trace("");
};
xmlListener.status = function(evt:Object) {
    trace("status::"+evt.code);
};
var myXMLConnector:XMLConnector = new XMLConnector();
myXMLConnector.addEventListener("result", xmlListener);
myXMLConnector.addEventListener("status", xmlListener);
myXMLConnector.direction = "receive";
myXMLConnector.URL = "http://www.flash-mx.com/mm/tips/tips.xml";
myXMLConnector.multipleSimultaneousAllowed = false;
myXMLConnector.suppressInvalidCalls = true;
myXMLConnector.trigger();
myXMLConnector.trigger();
myXMLConnector.trigger();

This code specifies the URL of the XML file and sets multipleSimultaneousAllowed to false. It triggers the XMLConnector instance three times, which causes the event listener's status method to display the error code CallAlreadyInProgress two times in the Output panel. The first attempt is successfully sent from Flash to the server. When the first trigger successfully receives a result, the result event is broadcast and the XML packet you receive is displayed in the Output panel.