I think I know why it crashes (Although it should not crash the browser - it should fail with a Flash null object error. You should file a bug).
When a right click event happens, a mouse out event happens first (Why? I don't know. Maybe this is a bug too) so your mouseOt function gets called which removes the context menu item. I assume, at this point, that the eventlistener is no longer valid but the event has already fired and is trying to find somewhere to go. This is what causes the crash. The moral of this is that you should not remove something willy nilly like this. First make sure you do not need it any more and then remove it. --- In [email protected], "valdhor" <valdhorli...@...> wrote: > > Not here. I am still using Flash Player 9.0.124. > > > --- In [email protected], "jmfillman" <jmfillman@> wrote: > > > > Thank you for the follow-up. The blankMenu is actually a left over from my > > actual application and wasn't needed for this sample code. > > > > This worked fine in FlashPlayer 9, so must be a bug with 10. > > > > JF > > > > --- In [email protected], "valdhor" <valdhorlists@> wrote: > > > > > > I tried your code and it crashes my browser here. I could not find a way > > > to stop that behavior in my (Admittedly short) testing. > > > > > > The only thing that jumped out at me was that your blankMenu is a null > > > object as it is never instantiated. Unfortunately, even if it is > > > instantiated, the crashing continues. > > > > > > The one question I have is why you are assigning a blank menu on > > > mouseout? There is no reason to do this. If the mouse is no longer over > > > the button, there is no context menu. I would just ignore a mouseout > > > entirely. > > > > > > If I get some more time I will have another look. Other that that, maybe > > > someone else has a suggestion. > > > > > > > > > Steve > > > > > > > > > --- In [email protected], "jmfillman" <jmfillman@> wrote: > > > > > > > > Any suggestions? Am I doing something wrong? > > > > > > > > JF > > > > --- In [email protected], "jmfillman" <jmfillman@> wrote: > > > > > > > > > > The code below causes both IE and Firefox to crash (haven't tried > > > > > others). The problem seems to occure when removing an item from a > > > > > custom context menu. It doesn't even debug, just crashes the browser. > > > > > > > > > > If I add this one line: > > > > > > > > > > menu.customItems.pop(); > > > > > > > > > > then the browser crashes. If I remove it, if functions as expected. > > > > > > > > > > Please help. > > > > > > > > > > Sample code below: > > > > > > > > > > <?xml version="1.0" encoding="utf-8"?> > > > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > > > > > layout="absolute"> > > > > > <mx:Script> > > > > > <![CDATA[ > > > > > import mx.controls.Alert; > > > > > [Bindable] public var menu:ContextMenu; > > > > > [Bindable] public var blankMenu:ContextMenu; > > > > > > > > > > public function mouseOvr(event:MouseEvent):void > > > > > { > > > > > menu = new ContextMenu; > > > > > var addPop:ContextMenuItem = new > > > > > ContextMenuItem("Do Something"); > > > > > > > > > > addPop.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, newPop); > > > > > menu.customItems.push(addPop); > > > > > myButton.contextMenu = menu; > > > > > } > > > > > public function newPop > > > > > (event:ContextMenuEvent):void { > > > > > Alert.show("Hi"); > > > > > } > > > > > public function mouseOt(event:MouseEvent):void { > > > > > myButton.contextMenu = blankMenu; > > > > > menu.customItems.pop(); > > > > > } > > > > > ]]> > > > > > </mx:Script> > > > > > <mx:Button x="349" y="189" label="Button" width="101" > > > > > height="41" id="myButton" mouseOver="mouseOvr(event)" > > > > > mouseOut="mouseOt(event)"/> > > > > > </mx:Application> > > > > > > > > > > > > > > >

