4 Replies Latest reply on Feb 1, 2010 10:34 AM by Gregory Lafrance

    Accessing Function from another Component - FLEX

    choisington Level 1

      Hello All,

       

      I have a question.

       

      I have multiple .mxml files for a program I am building.

       

      One file is called ThisPopUp.mxml.

       

      I have it pop up using this function:

       

           public function addGridPopUp():void
                  {
                      thisPopUp = new ThisPopUp();
                      PopUpManager.addPopUp(ThisPopUp, this, true);
                      PopUpManager.centerPopUp(ThisPopUp);
                  }

       

      Inside ThisPopUp i have

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" color="#000000" title="Options" height="214" width="360" borderStyle="solid" borderThickness="3">
          <mx:Script>
              <![CDATA[
                  import mx.managers.PopUpManager;
                 
                 
                  public function ptions(event:MouseEvent):void
                  {
                      if(doNothing == selected)
                      {
                          PopUpManager.removePopUp(this);
                      }
                      else if (connect == selected)
                      {
                       (DO A FUNCTION FROM MY MAIN APPLICATION)
                      }
                      else if (compare == selected)
                      {
                       (DO A FUNCTION FROM MY MAIN APPLICATION)  
                      }
                  }
                             
              ]]>
          </mx:Script>

       

      <mx:RadioButtonGroup id="optionsRadioGroup"/>
          <mx:RadioButton id="doNothing" x="0" y="32" label="Do nothing" groupName="optionsRadioGroup" selected="true"/>
          <mx:RadioButton id="connect" x="0" y="58" label="Connect" groupName="optionsRadioGroup"/>
          <mx:RadioButton id="compare" x="0" y="84" label="Compare" groupName="optionsRadioGroup"/>
          <mx:Label x="0" y="6" text="Select an option:" fontWeight="bold"/>
          <mx:Button x="0" y="123" label="Done" click="options(event)"/>

       

       

      This is probably a simple question but I am having trouble with it.

       

      How do you made it execute a function from a different .mxml file?

       

      I set my functions as public but it still wont let me call them. For example if I want to call a function from the main file called: doDragDrop(event)

       

      how would I do that?

       

      Thanks in advanced.