4 Replies Latest reply on Oct 28, 2009 4:48 PM by cyber0897

    need help with accessing popup variables in main application

    cyber0897 Level 1

      hey guys... im having some trouble accessing variables in the popup from the main application.

      I have gone over tons of links on google, and the one article on the adobe labs about passing variables between popups, but it dosent answer my question...

       

      what i basically need to happn is, i need to have access to the "dataToSave" variable in the itemDetail.mxml file.

      and the variable needs to come back only if none of the fields are blank.

       

       

      the code i have is

      mainCropper.as

          public var win:itemDetails;
          public function itemClicking(event:Event):void{
              var temp:ImageData = event.target as ImageData;
              win = itemDetails(PopUpManager.createPopUp(this, itemDetails, true));
              win.title = "Enter Details";
              PopUpManager.centerPopUp(win);

       

          }

       

       

      itemDetail.mxml

      <?xml version="1.0" encoding="utf-8"?>
      <s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/halo" width="800" height="600">
          <s:layout>
              <s:BasicLayout/>
          </s:layout>
          <fx:Script>
              <![CDATA[
                  import mx.managers.PopUpManager;
                  import mx.controls.Alert;
                  import valueObjects.*;
                 
                 
                  public var dataToSave:ImageData;
                 
                 
                  private function windowClose(event:MouseEvent):void{
                      PopUpManager.removePopUp(this);
                  }
                  public function checkUploadDetails(event:Event):void{
                      if(confirmNoEmptyFields() == true){
                          Alert.show(description.text);
                          dataToSave = new ImageData;
                          dataToSave.Description = description.text;
                          dataToSave.FileName = fileName.text;
                          dataToSave.Location = location.text;
                          dataToSave.Photographer = photographer.text;
                          //saveImgAndData(dataToSave);
                          PopUpManager.removePopUp(this);
                      }
                  }
                  public function confirmNoEmptyFields():Boolean{
                      if(description.text == ""){
                          Alert.show("Description is empty");
                          return false;
                      }
                      if(fileName.text == ""){
                          Alert.show("File Name is empty");
                          return false;
                      }
                      if(location.text == ""){
                          Alert.show("Location is empty");
                          return false;
                      }
                      if(photographer.text == ""){
                          Alert.show("Photographer is empty");
                          return false;
                      }
                      return true;
                  }
              ]]>
          </fx:Script>
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <s:HGroup>
              <mx:Form id="uploadDetails" borderThickness="10">
                  <mx:FormItem>
                      <!--mx:Image id="img" scaleContent="true" width="250" height="250" /-->
                  </mx:FormItem>
                  <mx:FormItem label="Description:">
                      <s:TextArea id="description" width="100%" height="250" />
                  </mx:FormItem>
                  <mx:FormItem label="File Name:">
                      <s:TextInput id="fileName" width="100%" />
                  </mx:FormItem>
                  <mx:FormItem label="Location">
                      <s:TextInput id="location" width="100%" />
                  </mx:FormItem>
                  <mx:FormItem label="Photographer">
                      <s:TextInput id="photographer" width="100%" />
                  </mx:FormItem>
                  <mx:HBox>
                      <mx:FormItem label="Thumbnail Scale X">
                          <s:TextInput id="thumbnailX" />
                      </mx:FormItem>
                      <mx:FormItem label="Thumbnail Scale Y">
                          <s:TextInput id="thumbnailY" />
                      </mx:FormItem>
                  </mx:HBox>
                  <mx:FormItem>
                      <s:Button id="save" label="save" click="checkUploadDetails(event)" />
                      <s:Button id="cancel" label="Cancel" click="windowClose(event)" />
                  </mx:FormItem>
              </mx:Form>
          </s:HGroup>
      </s:Panel>

       

      Thank you soo much in advance!! i really appretiate your help!!