Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top