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>

Reply via email to