Shan’s Simple Examples: Using events (aka how to pass data from components)

There was some confusion in #flex yesterday. The question came up on how a child component could access the parent component. Eventually, it came down to they wanted to pass some data from the child back to the parent.

Well, the “black box” method of component programming says that we should use custom events to send data from the component back to the parent. I whipped up an example that uses both a basic custom event and a custom event that passes back data.

One note, when you create your own event that passes back data, you not only need to add your custom attributes, but you also need to override the clone() method. Look at the file in the source.

You can view the example here. As always, right-click to view the source.