the modal alert window causes your problem. When the modal Alert activates, it 'forces' your mouse to leave that sprite and hence making it think that a mouse rollOUT event took place. try this to verify:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" > <mx:Script> <![CDATA[ import mx.controls.Alert; private function mouseDoubleClickListener (event:MouseEvent):void { var cmt:Sprite=new Sprite(); cmt.graphics.lineStyle (2,0x000000, 1); cmt.graphics.beginFill (0xff0000,1) ; cmt.graphics.drawCircle(event.localX, event.localY, 10); cmt.graphics.endFill() ; a.rawChildren.addChild(cmt); cmt.hitArea=cmt; cmt.addEventListener(MouseEvent.ROLL_OVER, mouseOverListener); cmt.addEventListener(MouseEvent.ROLL_OUT, mouseOutListener); b.mouseEnabled=false; //} } private var ctr:int=0; private function mouseOverListener (event:MouseEvent):void { testtext.text="rollover: " +ctr.toString(); ctr++; } private function mouseOutListener (event:MouseEvent) :void { testtext.text=" rollout: " +ctr.toString(); ctr++; } ]]> </mx:Script> <mx:Panel id="a" mouseEnabled="false"> <mx:Canvas id="b" width="474" height="471" doubleClick="mouseDoubleClickListener(event)" doubleClickEnabled="true"/> </mx:Panel> <mx:Text id="testtext" text="Text"/> </mx:Application> You will see that the counter only increments once for every mouseover and mouse out. Cheers, -leds --- Sandwish <[EMAIL PROTECTED]> wrote: > Thanks,Gordon! > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application > xmlns:mx="http://www.adobe.com/2006/mxml" > layout="vertical"> > <mx:Script> > <![CDATA[ > import mx.controls.Alert; > > private function mouseDoubleClickListener > (event:MouseEvent):void > { > > var cmt:Sprite=new > Sprite(); > > cmt.graphics.lineStyle > (2,0x000000,1); > cmt.graphics.beginFill > (0xff0000,1); > cmt.graphics.drawCircle > (event.localX,event.localY,10); > > cmt.graphics.endFill(); > a.rawChildren.addChild > (cmt); > cmt.addEventListener > (MouseEvent.ROLL_OVER, mouseOverListener); > cmt.addEventListener > (MouseEvent.ROLL_OUT, mouseOutListener); > //} > } > > private function mouseOverListener > (event:MouseEvent):void > { > Alert.show("rollover"); > > } > > private function mouseOutListener > (event:MouseEvent):void > { > Alert.show("rollout"); > } > > ]]> > </mx:Script> > <mx:Panel id="a"> > <mx:Canvas id="b" width="500" height="500" > doubleClick="mouseDoubleClickListener(event)" > doubleClickEnabled="true"/> > </mx:Panel> > </mx:Application> > > Run the code and the problem is obvious. > > Regards. > > --- In flexcoders@yahoogroups.com, "Gordon Smith" > <[EMAIL PROTECTED]> wrote: > > > > It's not obvious to me why that would be > happening. Can you post > the > > code for a simple app which demonstrates the > problem? > > > > - Gordon > > > > ________________________________ > > > > From: flexcoders@yahoogroups.com > [mailto:[EMAIL PROTECTED] On > > Behalf Of Sandwish > > Sent: Tuesday, February 27, 2007 11:22 AM > > To: flexcoders@yahoogroups.com > > Subject: [flexcoders] How does sprite listener > work? > > > > > > > > I new a sprite and addeventlistener which listens > roll_over and > > roll_out event. But after a circle is drawn with > beginfill and > > endfill, each time I roll inside the circle, both > events get > invoked. > > I don't know why? :( > > > > Thanks in advance! > > Regards, > > Sand > > > > > ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com