humm..... if I skip the creationComplete handler, I got errors msg below...see code below...
Looks the component is not ready to use Listener. 1120: Access of undefined property moveHandler. 1120: Access of undefined property panel_02 Thanks ==================================================================== <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import flash.events.Event; //import mx.core.*; import mx.events.MoveEvent; panel_02.addEventListener(MoveEvent.MOVE, moveHandler); private function moveHandler(event:Event):void { panel_01.title = "Detected" trace("got"); } private function movePanel(event:Event):void{ panel_02.move(350,109); } ]]> </mx:Script> <mx:Panel id="panel_01" x="64" y="109" width="250" height="200" layout="absolute"> <mx:TextInput id="textInput" x="35" y="40"/> </mx:Panel> <mx:Panel id="panel_02" x="432" y="109" width="250" height="200" layout="absolute"> </mx:Panel> <mx:Button x="346" y="390" label="Button" click="movePanel(event);"/> </mx:Application> =============================================================== --- In [email protected], "Gordon Smith" <[EMAIL PROTECTED]> wrote: > > Register for MoveEvent.MOVE on the Panel. A Panel doesn't dispatch > Event.CHANGE when it is moved, it dispatches MoveEvent.MOVE. And you can > more easily register for this event by writing > > <mx:Panel id="panel_01" x="64" y="109" width="250" height="200" > layout="absolute" move="moveHandler(event)"/> > > There's no need to do it by calling addEventListener() inside the > Application's creationComplete handler. > > - Gordon > > ________________________________ > > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of Sheriff > Sent: Thursday, September 13, 2007 1:05 PM > To: [email protected] > Subject: Re: [flexcoders] Simple addEventListener Question! > > > > i think u would need to call the invalideDisplayList() on panel_01 but i > am not sure > > > ----- Original Message ---- > From: flexawesome <[EMAIL PROTECTED]> > To: [email protected] > Sent: Thursday, September 13, 2007 2:47:58 PM > Subject: [flexcoders] Simple addEventListener Question! > > > > > hey there, > > I am working on the addEventListener and I would like to change the > title for "panel_01" once "panel_02" has moved, there is no error for > the code below, but won't work. > > Do you have any suggestion? Thanks > > ============ ========= ========= ========= ========= ========= = > <?xml version="1.0" encoding="utf- 8"?> > <mx:Application xmlns:mx="http://www.adobe. com/2006/ mxml > <http://www.adobe.com/2006/mxml> " > layout="absolute" creationComplete= "initApp( event)"> > <mx:Script> > <![CDATA[ > > import flash.events. Event; > import mx.core.* > > private function initApp(event: Event):void{ > panel_02.addEventLi stener(Event. CHANGE, moveHandler) ; > } > > > private function moveHandler( event:Event) :void { > panel_01.title = "Detected" > trace("got") ; > } > > private function movePanel(event: Event):void{ > panel_02.move( 350,109); > > } > > ]]> > </mx:Script> > > <mx:Panel id="panel_01" x="64" y="109" width="250" height="200" > layout="absolute" > > </mx:Panel> > > <mx:Panel id="panel_02" x="432" y="109" width="250" height="200" > layout="absolute" > > </mx:Panel> > <mx:Button x="346" y="390" label="Button" click="movePanel( event);"/ > > > </mx:Application> > ============ ========= ========= ========= ========= ========= = > > > > > > ________________________________ > > Moody friends. Drama queens. Your life? Nope! - their life, your story. > Play Sims Stories at Yahoo! Games. > <http://us.rd.yahoo.com/evt=48224/*http://sims.yahoo.com/> >

