1 Reply Latest reply on Mar 26, 2007 10:53 AM by holmes_z06

    Passing Variable to Component

      Hi all,

      I was wondering if there was anyone who may help me out with this particular problem that I have. I'm trying to pass a the value of a selected item from a combobox from the parent application to a component embedded into the parent app. If I can pass the value to a text control that would be great.

      Basically, I have combo boxes that drive the filtering within a a custom component. I think I have everything else figured out except the passing of variables.

      Again, if anyone can provide any type of assistance, thanks in advance!
        • 1. Re: Passing Variable to Component
          Read up on this thing called MVC. :)

          Have each of your views know about a controller. When an event occurs on the view, dispatch an event to the controller. The controller will then do whatever action is necessary. If that means change the value in another view, it can dispatch an event to that view.

          View 1 combo box changes.
          controller.addEventListener("event1", controller.onSelectChange);
          comboBox.addEventListener(ComboBoxEvent.CHANGE, function() {
          view1.dispatchEvent(new Event1(YourEvents.EVENT_1));

          function onSelectChange(evnt:Event):void {
          //do something business-like
          dispatchEvent(new Event2(YourEvents.EVENT_2))

          View 2
          //in constructor register as listener
          controller.addEventListener(YourEvents.EVENT_2, onEvent2);

          function event2(YourEvent:event):void {
          //update the text control

          I have no idea if that code will compile, but it's essentially what you want to do to have an extendable program.