Removing old elements from menu.dataDescriptor

hi guys

I have something like  

addEventListener(MenuEvent.ITEM_ROLL_OVER, mouseRollHandler);
...

private function mouseRollHandler(event:MenuEvent):void{
if(event.item.hasOwnProperty("children")){
displayMenu(event.index);
}
}

private function displayMenu(index:Number):void
    {
var menu:Menu = getMenuAt(index);
...
menu.dataDescriptor     (is of the type : mx.controls.treeClasses.DefaultDataDescriptor)
menu.dataDescriptor  has ChildCollectionCache (of type flash.utils.Dictionary)
ChildCollectionCache  has four elements

object4
object3
object2
object1

Every time a menu item is focused on, it gets added to ChildCollectionCache.

I want to keep the latest menu item which is focused and remove the rest of items everytime. anyidea how i can do it?

for example
I want to keep only object4  and remove object 3,2,1

Any help will be greatly appreciated

thanks
royjaydAsked:
Who is Participating?
 
dgofmanCommented:
You code is incomplete I cannot understand where is your dataProvider and what items you want to update?
0
 
dgofmanCommented:
Can you provide code of your implementation of MenuBar / Menu / PopupMenu no idea what component are you using???
0
 
royjaydAuthor Commented:
public class RollOverMenuBar extends MenuBar {
public function RollOverMenuBar () {
super();
addEventListener(MenuEvent.ITEM_ROLL_OVER, mouseRollHandler);
}

private function mouseRollHandler(event:MenuEvent):void{
if(event.item.hasOwnProperty("children")){
displayMenus(event.index);
}
}

 private function displayMenus(index:Number):void
  {
 isMenuHide = false;
  selectedIndex = index;
 var item:IMenuBarItemRenderer = menuBarItems[index];
 var menu:Menu = getMenuAt(index);
 if (!menu.parent)
 {
  menu.focusEnabled = true;
  PopUpManager.addPopUp(menu, this, false);
  menu.addEventListener(MenuEvent.MENU_HIDE, menuHide, false, EventPriority.DEFAULT_HANDLER);
  }
       
  var pt:Point = new Point(0, 0);
    menu.show(pt.x, pt.y);
    }
 private  function menuHide(event:MenuEvent):void
    {
   var menutoremove:Menu = Menu(event.target);
    isMenuHide = true;
   PopUpManager.removePopUp(menutoremove);

      }      
      
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.