0 Replies Latest reply on Oct 14, 2007 1:01 AM by Giribabums

    passing parameters

    Giribabums Level 1
      In 1st component i have placed 14 ComboBox controls and 2 checkboxs, In 2nd Component i created 2 ComboBox and a Button control [btnApply]. When i click on Apply button after selecting the values from the ComboBox i Want to reflect the changes in 1st component. means i want to set all ComboBox values in 1st component to the values which i selected in 2nd Components. just check the code which i included with this post, when i click on chkDailyM2F checkBox it is creating 2 TitleWindow I dont want to create Morethan 1 titleWindow. i want to display single TitleWindow and want to change the values of comboBoxs in 1st component. how can i achieve this, is there any alternative way. please help me on this issue.
      I tried to access public variable but no use. my second question is how can i return 2 values from a method. when i call a method i want to return 2values, how can i achieve it?

      [code]
      <?xml version="1.0" encoding="utf-8"?>
      //1st component code - mainApp.mxml
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%" horizontalScrollPolicy="off" creationComplete="GenerateTime();">
      <mx:Script>
      <![CDATA[
      private var timeInAm:int = 0;
      private var point1:Point = new Point();

      [Bindable]
      private var TimeArrCollection:ArrayCollection = new ArrayCollection();

      private function GenerateTime():void
      {
      CursorManager.setBusyCursor();
      var tmpArr:Array = new Array(11);
      for(var i:int = 0; i <= 11; i++)
      {
      timeInAm = timeInAm + 1;
      tmpArr = timeInAm;
      }
      for(var AM:int = 0; AM <= 11; AM++)
      {
      TimeArrCollection.addItem({ data: tmpArr[AM], label: tmpArr[AM] + ":00 AM" });
      }
      var counter:int = tmpArr.length;
      for(var PM:int = 0; PM < tmpArr.length; PM++)
      {
      counter = counter + 1;
      TimeArrCollection.addItem({ data: counter, label: tmpArr[PM] + ":00 PM" });
      }
      }
      private function chkDailyAll_Change(event:Event):void
      {
      if(chkDailyAll.selected)
      {
      chkDailyM2F.selected = false;
      GetSelectedTime(chkDailyM2F, ddlMonAfter, ddlMonBefore);
      }
      }
      private function chkDailyM2F_Change(event:Event):void
      {
      if(chkDailyM2F.selected)
      {
      chkDailyAll.selected = false;
      GetSelectedTime(chkDailyM2F, ddlMonAfter, ddlMonBefore);
      GetSelectedTime(chkDailyM2F, ddlTueAfter, ddlTueBefore);
      }
      }
      private function GetSelectedTime(selectedCheckBox:CheckBox, sAfterID:ComboBox, eBeforeID:ComboBox):void
      {
      var StartEndTime:SetAfterBeforeTime = SetAfterBeforeTime(PopUpManager.createPopUp(this,SetAfterBeforeTime,true));

      point1.x = selectedCheckBox.x;
      point1.y = selectedCheckBox.y;
      point1 = selectedCheckBox.localToContent(point1);
      StartEndTime.x = point1.x+10;
      StartEndTime.y = point1.y+10;
      StartEndTime.startAfter = sAfterID;
      StartEndTime.endBefore = eBeforeID;
      }
      ]]>
      </mx:Script>
      <mx:Panel x="10" y="0" width="664" height="157" layout="absolute" title="Main App " cornerRadius="2">
      <mx:VBox width="100%" height="100%" verticalGap="1">
      <mx:Spacer height="5" width="100%"/>
      <mx:HBox horizontalGap="1" width="100%" paddingLeft="5" paddingRight="5">
      <mx:VBox horizontalAlign="right" height="100%" verticalAlign="bottom">
      <mx:Label text="After"/>
      <mx:Label text="Before"/>
      <mx:Spacer height="0.5"/>
      </mx:VBox>
      <mx:Spacer width="5" height="100%"/>
      <mx:VBox>
      <mx:ComboBox width="85" id="ddlSunAfter" dataProvider="{TimeArrCollection}"></mx:ComboBox>
      <mx:ComboBox width="85" id="ddlSunBefore" dataProvider="{TimeArrCollection}"></mx:ComboBox>
      </mx:VBox>
      <mx:VBox>
      <mx:ComboBox width="85" id="ddlMonAfter" dataProvider="{TimeArrCollection}" ></mx:ComboBox>
      <mx:ComboBox width="85" id="ddlMonBefore" dataProvider="{TimeArrCollection}" ></mx:ComboBox>
      </mx:VBox>
      <mx:VBox>
      <mx:ComboBox width="85" id="ddlTueAfter" dataProvider="{TimeArrCollection}"></mx:ComboBox>
      <mx:ComboBox width="85" id="ddlTueBefore" dataProvider="{TimeArrCollection}"></mx:ComboBox>
      </mx:VBox>
      <mx:VBox>
      <mx:ComboBox width="85" id="ddlWedAfter" dataProvider="{TimeArrCollection}"></mx:ComboBox>
      <mx:ComboBox width="85" id="ddlWedBefore" dataProvider="{TimeArrCollection}"></mx:ComboBox>
      </mx:VBox>
      <mx:VBox>
      <mx:ComboBox width="85" id="ddlThuAfter" dataProvider="{TimeArrCollection}"></mx:ComboBox>
      <mx:ComboBox width="85" id="ddlThuBefore" dataProvider="{TimeArrCollection}"></mx:ComboBox>
      </mx:VBox>
      <mx:VBox>
      <mx:ComboBox width="85" id="ddlFriAfter" dataProvider="{TimeArrCollection}"></mx:ComboBox>
      <mx:ComboBox width="85" id="ddlFriBefore" dataProvider="{TimeArrCollection}"></mx:ComboBox>
      </mx:VBox>
      <mx:VBox>
      <mx:ComboBox width="85" id="ddlSatAfter" dataProvider="{TimeArrCollection}"></mx:ComboBox>
      <mx:ComboBox width="85" id="ddlSatBefore" dataProvider="{TimeArrCollection}"></mx:ComboBox>
      </mx:VBox>
      </mx:HBox>
      <mx:HBox horizontalAlign="center" width="100%" height="100%" horizontalGap="1">
      <mx:HBox width="100%" horizontalAlign="center" height="100%" verticalAlign="middle">
      <mx:CheckBox label="Daily (ALL)" id="chkDailyAll" change="chkDailyAll_Change(event);"/>
      <mx:CheckBox label="Daily (M ~ F)" id="chkDailyM2F" change="chkDailyM2F_Change(event);"/>
      </mx:HBox>
      <mx:HBox horizontalAlign="right" paddingRight="10" height="100%" verticalAlign="middle">
      <mx:Button id="btnMainAppApply" label="Apply"/>
      </mx:HBox>
      </mx:HBox>
      </mx:VBox>
      </mx:Panel>
      </mx:Canvas>
      [/code]
      [code]
      <?xml version="1.0" encoding="utf-8"?>
      // 2nd component code - SetAfterBeforeTime.mxml
      <mx:TitleWindow xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="210" height="142" showCloseButton="true" close="PopUpManager.removePopUp(this)" title="SELECT TIME" creationComplete="GenerateTime();">
      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;
      import mx.collections.ArrayCollection;
      import mx.managers.CursorManager;
      import mx.controls.ComboBox;
      import mx.managers.PopUpManager;
      public var startAfter:ComboBox;
      public var endBefore:ComboBox;
      private var timeInAm:int = 0;
      [Bindable]
      public var TimeArr:ArrayCollection = new ArrayCollection();
      private function returnSelectedTime():void {
      startAfter.selectedIndex = ddlStartAfter.selectedIndex;
      endBefore.selectedIndex = ddlEndBefore.selectedIndex;
      PopUpManager.removePopUp(this);
      }
      private function GenerateTime():void
      {
      CursorManager.setBusyCursor();
      var tmpArr:Array= new Array(11);
      for(var i:int = 0; i <= 11; i++)
      {
      timeInAm = timeInAm + 1;
      tmpArr = timeInAm;
      }
      for(var AM:int = 0; AM <= 11; AM++)
      {
      TimeArr.addItem({ data: tmpArr[AM], label: tmpArr[AM] + ":00 AM" });
      }
      var counter:int = tmpArr.length;
      for(var PM:int = 0; PM < tmpArr.length; PM++)
      {
      counter = counter + 1;
      TimeArr.addItem({ data: counter, label: tmpArr[PM] + ":00 PM" });
      }
      CursorManager.removeBusyCursor();
      }
      ]]>
      </mx:Script>
      <mx:Label x="14" y="10" text="Start After"/>
      <mx:Label x="10" y="36" text="End Before"/>
      <mx:ComboBox id="ddlStartAfter" dataProvider="{TimeArr}" x="83" y="8" width="95"></mx:ComboBox>
      <mx:ComboBox id="ddlEndBefore" dataProvider="{TimeArr}" x="83" y="34" width="95"></mx:ComboBox>
      <mx:Button x="122" y="70" label="Close" id="btnClose" click="returnSelectedTime();"/>
      </mx:TitleWindow>
      [/code]