2 Replies Latest reply on Sep 13, 2010 8:03 AM by Gregory Lafrance

    accessing elements of mxml in actionscript


      how to access mxml elements from actionscript?

        • 1. Re: accessing elements of mxml in actionscript
          jfb00 Level 3


          Just add and ID to your mxml component and use that name in actionscript like:

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600" creationComplete="init()">
                      import mx.controls.Alert;
                      private function init():void{
              <mx:Label id="Test" text="My Test" />

          I hope this help.



          • 2. Re: accessing elements of mxml in actionscript
            Gregory Lafrance Level 6

            And when using components you may need to "chain" your id references.


            So if you have an MXML component MyComp, and if that component has a label with an id of myLabel, and if in the main app file you create an instance of the component myCompInst:




            If this post answers your question or helps, please mark it as such.

            Greg Lafrance - Flex 2 and 3 ACE certified


            Flex Training and Support Services