6 Replies Latest reply on May 13, 2009 1:38 AM by flexynewbie

    How to identify a component in ActionScript

    flexynewbie

      Hi everybody,

       

      I have a following problem. I need to identify a component in ActionScript so that I know which component I am dealing at the moment. In my case these components are VideoDisplays but I guess it works the same for any others.

       

      Assuming that I have the following MXML:

       

                      <mx:Canvas visible="false" x="0" y="0" width="229" height="434" id="canvas">

                          <mx:VideoDisplay click="activateControls(event);" x="10" y="113" width="198" height="111" source="video/1.flv" id="lap1_video"/>
                          <mx:VideoDisplay click="activateControls(event);" x="10" y="260" width="198" height="133" source="video/2.flv" id="lap2_video"/>
                          <mx:VideoDisplay click="activateControls(event);" x="10" y="429" width="198" height="108" source="video/3.flv" id="lap3_video"/>
                      </mx:Canvas>

       

      I would like my function activateControls(event) to distinguish between the VideoDisplays. So i've tried the following:

       

                  private function activateControls(event:MouseEvent):void
                  {

                      if (event.id)
                      {
                          //then
                      }

                  }

       

      But it appears that I cannot read the id of the object in ActionScript. I am pretty sure there must be a way to do it. Please let me know how to do it or if there is a better way to identify a component in ActionScript.

       

      Thanks,

      flexynewbie