3 Replies Latest reply on Jan 25, 2010 6:51 AM by edwinmerced

    Making it more efficient

    edwinmerced Level 1

      I will be using this function

       

                     private function inter_1a(evt:MouseEvent):void {
                      var popUpInterDisplay:interactionexporter;
                      popUpInterDisplay = new interactionexporter();
                      popUpInterDisplay.source = "lessons/lessonone/interactions/inter1a.swf";
                      PopUpManager.addPopUp(popUpInterDisplay, this, true);
                  }

       

      But will use it at least 30 times. For example:

       

                     private function inter_1b(evt:MouseEvent):void {
                      var popUpInterDisplay:interactionexporter;
                      popUpInterDisplay = new interactionexporter();
                      popUpInterDisplay.source = "lessons/lessonone/interactions/inter1b.swf";
                      PopUpManager.addPopUp(popUpInterDisplay, this, true);
                  }

       

       

                 private function inter_1c(evt:MouseEvent):void {
                       var popUpInterDisplay:interactionexporter;
                       popUpInterDisplay = new interactionexporter();
                       popUpInterDisplay.source = "lessons/lessonone/interactions/inter1c.swf";
                       PopUpManager.addPopUp(popUpInterDisplay, this, true);
                   }

       

          ETC......

       

      Any ideas as to make this more efficient?

       

      Thanks

        • 1. Re: Making it more efficient
          archemedia Level 4

          This can be written more efficient indeed. How are these functions called, by Buttons or by an item in a datagrid?

           

          In case it are buttons, you can store the name of the swf in their id properties:

           

          private function inter(evt:MouseEvent):void

          {
                var popUpInterDisplay:interactionexporter = new interactionexporter();
                popUpInterDisplay.source = "lessons/lessonone/interactions/" + evt.target.id + ".swf";
                PopUpManager.addPopUp(popUpInterDisplay, this, true);
          }

           

          In case of a datagrid, you can use a property of the selectedItem:

           

           

          private function inter(evt:MouseEvent):void

          {
                 var popUpInterDisplay:interactionexporter = new interactionexporter();
                 popUpInterDisplay.source = "lessons/lessonone/interactions/" + evt.currentTarget.selectedItem.propName + ".swf";
                 PopUpManager.addPopUp(popUpInterDisplay, this, true);
          }

           

          Dany

          1 person found this helpful
          • 2. Re: Making it more efficient
            edwinmerced Level 1

            Dany Thank you Very Much!!! I used the button version.

            • 3. Re: Making it more efficient
              edwinmerced Level 1

              Thanks to the participnts nd to the forum organizers for providing this learning space!