5 Replies Latest reply on Jun 26, 2008 4:11 PM by chonchonchon

    Component / dispatching

    chonchonchon
      Hi
      I was wondering if anyone could give me some pointers on a simple problem I`m muddling through.
      It`s basically to do with communication between components and parent app.

      The problem is that there is a varying number of the same component being added to the app and I can't work out how to target them. I`m adding them on a button click like this:

      var newBox:textItem = new textItem;
      someContainer.addChild(newBox);
      newBox.addEventListener("login", loginHandler);

      The textItem component dispatches an event when it is clicked

      var e:LoginEvent = new LoginEvent("login", this.name,);
      dispatchEvent(e);

      All the dispatching stuff works fine, i`m sending "this.name" back in there because in the main app I am trying to find out which instance of the component is reporting back. I`m sure this isn't the way!

      Anyway, after I`ve got the name of the component as a string, I can`t work out how to get Flex to use it to target the component - how do i change it from a string to something I can use as a component id?

      I guess basically the main points are;
      1. Do you assign an ID when you addChild()?
      2. How would you find the ID of and target dynamically added components?

      Thanks very much for any help at all