1 Reply Latest reply on Jan 26, 2009 4:55 PM by Newsgroup_User

    Listening for click event

    spacehog
      I am curious, how can you have a child mxml page listen for an event from the parent?

      Let's say you have a button, call it 'btn1' on page1.mxml and you want to listen for the click event on page2.mxml. So far this is what I have:

      page1.mxml:

      <mx:Button id="btn1" />

      page2.mxml:

      <mx:Script>
      <![CDATA[


      private function btnListener(e:MouseEvent){
      Application.application.btn.addEventListener(MouseEvent.CLICK, setState(1));
      }
      ]]>
      </mx:Script>


        • 1. Re: Listening for click event
          Level 7

          "spacehog" <webforumsuser@macromedia.com> wrote in message
          news:glljts$g04$1@forums.macromedia.com...
          >I am curious, how can you have a child mxml page listen for an event from
          >the
          > parent?
          >
          > Let's say you have a button, call it 'btn1' on page1.mxml and you want to
          > listen for the click event on page2.mxml. So far this is what I have:
          >
          > page1.mxml:
          >
          > <mx:Button id="btn1" />
          >
          > page2.mxml:
          >
          > <mx:Script>
          > <![CDATA[
          >
          >
          > private function btnListener(e:MouseEvent){
          > Application.application.btn.addEventListener(MouseEvent.CLICK,
          > setState(1));
          > }
          > ]]>
          > </mx:Script>

          Check out Q3:
          http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf