6 Replies Latest reply on Apr 10, 2009 1:28 PM by phillipus_rex

    Components:  Communication Between Buttons on Component and Application

    phillipus_rex Level 1

      This is probably a lot simpler than I am making it out to be ... but, I'm totally stuck, so here goes:



      I have a seperate component that acts as a container for a group of buttons.  The container is scrollable vertically, and has arrows at the top and bottom to activate the scroll effect.  So the id is "scroll_arrow".


      Here is my problem:  I need to populate a datagrid with the id="patient_stream" with the data coming from an array collection that is specific to the particular button that I am pressing.


      The component cannot "see" the items within the application, so I cannot apply functions directly to the buttons.


      I attempted this:


      Again, "scroll_arrow" is the component.  "first_responder" is the button.  "patient_stream" is the datagrid.  "head_area" is the Arraycollection.

      public function load(event:MouseEvent):void
                      if (scroll_arrow.first_responder.selected == true)
                          patient_stream.dataProvider = head_area;


      However, I have no way of activating the "load" function, because Ithe component and the application are seperate.


      I am attaching the code for the component so that you can get a better idea of what I am attempting to do.


      Does anyone have a better solution on handling this?






      <?xml version="1.0" encoding="utf-8"?>
      <mx:VBox   xmlns:mx="http://www.adobe.com/2006/mxml" 
                  import flash.utils.clearInterval;
                  import flash.utils.setInterval;
                  import mx.effects.easing.Exponential;
                  import mx.effects.AnimateProperty;
                  private var fx:AnimateProperty = new AnimateProperty();
                  private var index:uint;
                  private function onMouseWheel(e:MouseEvent):void
                  private function doDown():void
                      index = setInterval(doMove,300,100);
                  private function doUp():void
                      index = setInterval(doMove,300,-100);
                  private function clear():void
                  private function doMove(direction:Number):void
                      fx.property = "verticalScrollPosition";
                      fx.easingFunction = Exponential.easeOut;
                      fx.toValue = box.verticalScrollPosition + direction;
              <mx:Button upSkin="@Embed(source='/images/query_up_1.png')" overSkin="@Embed(source='images/query_up_1.png')" downSkin="@Embed(source='images/query_up_2.png')" mouseDown="doUp()" mouseUp="clear()" doubleClickEnabled="true" color="#F5F8F9" width="258"/>
                  <mx:VBox id="box" width="280" height="{height - 250}" horizontalScrollPolicy="off" horizontalAlign="center" verticalScrollPolicy="off">
                           <mx:Button   label="1RSP First Responder – Medical"  width="261" height="29" labelPlacement="left" textAlign="left" fontSize="10" id="first_responder"/>
                           <mx:Button    width="261" height="29"  label="BAS Battalion Aid Station" textAlign="left" fontSize="10"/>
                           <mx:Button    width="261" height="29" label="FRSS Pre-op" textAlign="left" fontSize="10"/>
                            <mx:Button    width="261" height="29" label="FRSS Operating Room" textAlign="left" fontSize="10"/>
                           <mx:Button    width="261" height="29" label="FRSS Post-op" textAlign="left" fontSize="10"/>
                           <mx:Button  width="261" height="29" label="SC Operating Room" textAlign="left" fontSize="10"/>
                           <mx:Button  width="261" height="29" label="SC Ward" fontSize="10" textAlign="left" fontFamily="Verdana"/>
                           <mx:Button  width="261" height="29" label="SC X-ray" fontSize="10" textAlign="left"/>
                           <mx:Button  width="261" height="29" label="SC Laboratory" textAlign="left" fontSize="10"/>
                           <mx:Button  width="261" height="29" label="Operating Room Equipment" textAlign="left" fontSize="10"/>
                           <mx:Button  width="261" height="29" label="Operating Room Consumables" textAlign="left" fontSize="10"/>
                           <mx:Button  width="261" height="29" label="Field Dental Operatory" textAlign="left"/>
                           <mx:Button  width="261" height="29" label="NBC Individual" textAlign="left"/>
                           <mx:Button  width="261" height="29" label="NBC Unit" textAlign="left"/>
                           <mx:Button  width="261" height="29" label="Aid Station Sick Call" textAlign="left"/>
                           <mx:Button  width="261" height="29" label="1st Resp - Consumable" textAlign="left"/>
                           <mx:Button  width="261" height="29" label="1RE 1st Resp - Equipment" textAlign="left"/>
                           <mx:Button  width="261" height="29" label="PMM" textAlign="left"/>
                           <mx:Button  width="261" height="29" label="PMT" textAlign="left"/>
                           <mx:Button  width="261" height="29" label="OEHS" textAlign="left"/>
                           <mx:Button  width="261" height="29" label="ENTO" textAlign="left"/>
                           <mx:Button  width="261" height="29" label="BEC BAS ERC - Consumable" textAlign="left"/>
                          <mx:Button width="258" upSkin="@Embed(source='/images/query_down_1.png')" overSkin="@Embed(source='images/query_down_1.png')" downSkin="@Embed(source='images/query_down_2.png')"  mouseDown="doDown()" mouseUp="clear()" />