4 Replies Latest reply on Aug 25, 2009 2:04 PM by KomputerMan.com

    Quick ActionScript question

    KomputerMan.com Level 1

      Below is a function I am calling when a database event is successfully completed.  What I need to do is call another function on a dynamically provided form name when the following function gets processed.  I am passing in the name of the form to call in the event.result array.  My question is how do I reference the page where the function that I want to run resides?


      private function ConfigAddedRetHandler(event:ResultEvent):void
      var myComp:String = "DropDown_TabNav_ID." + event.result[0].CallingComp;

      // One of the values that could be returned by the event.result[0].CallingComp is "ClientStatusID".
      this[myComp].Input_CurrentLabel.text = "";



      for( var i:int = 0; i < model.configurations.length; i++){
        if(model.configurations[i].CompName == 'ClientStatusID'){
        DropDown_TabNav_ID.ClientStatusID.Input_CurrentLabel.text = "";



      My question is why doesn't the line: this[myComp].Input_CurrentLabel.text = ""; work even though the value for this is set to "DropDown_TabNav_ID.ClientStatusID"



      This line works just fine:  DropDown_TabNav_ID.ClientStatusID.Input_CurrentLabel.text = "";


      A few other items: I store several component names in the model.configurations array, one of which is ClientStatusID.  I need this function to be pretty generic so I can call one of several similar functions depending on the name of the component returnd in the event. 



      Thanks in advance for the help!!!


      Kurtis   ~|:-)

        • 1. Re: Quick ActionScript question
          KomputerMan.com Level 1

          OK lets try this again.  The following code is more than a little ugly.  It is basically the same stuff over and over again with the only difference being two strings.  Both of these strings are passed in with my event results.  My question is how do I replace the word "ClientStatusID" in the code below with the value contained in event.result[0].CallingComp?





          private function ConfigAddedRetHandler(event:ResultEvent):void



          for(var i:int = 0; i < model.configurations.length; i++){


            if(model.configurations[i].CompName == event.result[0].CompName){

              model.configurations[i].CompLabel = event.result[0].CompLabel;




              if(model.configurations[i].CompName == 'ddClientStatusID'){

                DropDown_TabNav_ID.ClientStatusID.Input_CurrentLabel.text =




                DropDown_TabNav_ID.ClientStatusID.ddClientStatusID.checkLabelYet = 0;





          else if(model.configurations[i].CompName == 'ddExpenseTypesID'){

               DropDown_TabNav_ID.ExpenseTypesID.Input_CurrentLabel.text = "";


                DropDown_TabNav_ID.ExpenseTypesID.ddExpenseTypesID.checkLabelYet = 0;





          else if(model.configurations[i].CompName == 'ddPhoneTypesID'){

                DropDown_TabNav_ID.PhoneTypesID.Input_CurrentLabel.text =




                DropDown_TabNav_ID.PhoneTypesID.ddPhoneTypesID.checkLabelYet = 0;








            Thanks again...

          • 2. Re: Quick ActionScript question
            injpix Level 3

            Have you tried to cast this object?  In your case, I would try the following:


            var callingComp:CustomComp = event.result[0].CallingComp as CustomComp;

            callingComp.Input_CurrentLabel.text = "";



            callingComp.ddClientStatusID.checkLabelYet = 0;





            As CustomComp would be the data type the object should be or subclass from.   I am not sure why you would need to have the DropDown_TabNav_ID object in the lines of code above, so I obviously did not post them.  An Event object will have reference to the that object in the result array.  So I don't see the need to append  DropDown_TabNav_ID.


            • 3. Re: Quick ActionScript question
              KomputerMan.com Level 1

              It doesn't complile...  is that CustComp some sort of package I have to create first???


              It can't believe that this is all that difficult to do. All I want to do is to substitute a variable into the path of a component/function I want to call...



              The word "DropDown_TabNav_ID" is the name of a component that contains the name of the component that is defined in "event.result[0].CallingComp". I.E event.result[0].CallingComp could equal PhoneTypesID.


              event.result[0].CompName is set to one of the names like "ddPhoneTypesID".


              My question is how do I replace the string:


              with something like this that actually works:


              Thanks in advance for your help!!!

              • 4. Re: Quick ActionScript question
                KomputerMan.com Level 1

                THIS IS THE ANSWER





                I needed to take out the plus signs (+) and the dots notation... I knew it had to be something simple!!!   Thanks to Slowburn on Actionscript.org!!!