0

I have 2 custom components in Flash Builder, A.mxml which contains B.mxml. B has a text input, and every time the text is changed I would like to call a "save()" function on A.

The relevant code in B is:

<fx:Metadata>
    [Event(name="customChange", type="flash.events.Event")]
</fx:Metadata>

...

<s:TextInput text="@{value}" valueCommit="{dispatchEvent(new Event(Event.CHANGE))}"/>

I can replace the code in valueCommit="{}" with a trace statement, and confirm that it's working as expected.

The relevant code in A is:

<widgets:B customChange="{save()}"/>

However save() is never getting called.

Why is the event not reaching A?

ario
  • 1,727
  • 4
  • 19
  • 28

1 Answers1

2

The metadata in your class (B.mxml) says it dispatches an event who's type/name is "customChange":

[Event(name="customChange", type="flash.events.Event")]

But the component is dispatching Event.CHANGE -- the type/name for this event is just "change".

You have two options:

  • Change your meta data to use the the same event type/name that you are dispatching:

    [Event(name="change", type="flash.events.Event")]

  • Create your own event class and dispatch that, then modify the meta data to specify that your custom event class is dispatched by B.mxml

Sunil D.
  • 17,983
  • 6
  • 53
  • 65
  • Aha, I thought the name field simply indicated what you wanted the property on the MXML widget to be called. Thanks for the clarification! – ario Jul 27 '12 at 21:07