Don’t do this during Flex job interviews

But do it after you got hired.

A custom component A (written in Flash) sends a custom event with parameters to a component B (written in Flex), and the latter needs to pass received event’s parameters to Flex  Application object. The code below just traverses through all parameters of the dynamic custom event and assigns them to the corresponding properties in the Application object.

private function passParamsToApp (event:MyGreatEvent):void{
// this code can be used in preloaders that need to load fast small Flash swc
// getDefByName syntax allow to avoid pre-linkage of the Application obj 
var anApp:Object = getDefinitionByName ("mx.core.Application").application;

for (var i:String in event) {
        anApp [i] = event [i];
   } catch (e:Error) {
      trace ("There is no parameter " + i +  "in " + anApp + " defined");

The custom event is also defined not by the book (actually, it’s in our book) – it has no clone() function, no metadata tags, and no officially declared custom properties:
public dynamic class MyGreatEvent extends Event{

   public function MyGreatEvent(type:String, customerID:String, someOtherJunk:XML){
      this.customerID = customerID;
      this.someOtherJunk = someOtherJunk;

You can read more about Flex apps using a single event here:

As you see, this code in the for loop works on the assumption that the Application object has setters or the public properties with names that match parameters of the event (customerID and someOtherJunk).

But even this requirement can be overcome if you’ll use dynamic application object as explained in Chapter 2 of our upcoming book “Enterprise Programming with Flex.” (Anatole, Victor, and myself have a high-priority task to submit the final two chapters to O’Reilly in two weeks).

If you’ll offer something like this during the Flex job interview answering the question,  “How to pass parameters from a custom component to Application object?”, you’ll get burned by object-oriented purists.  The kosher answer in the interview situation is a well prepared speach about the Mediator pattern as explained here

But if I’ll be running this interview, you are hired!