Adobe Solution Partner

March 19, 2008

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

Filed under: Flex & Flash, Shan's Simple Examples — Tags: , — Shannon Hicks @ 7:35 am

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 MyCustomEvent.as file in the source.

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

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • StumbleUpon
  • Technorati
  • TwitThis

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment