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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dgofmanCommented:
Can you provide code of your implementation of MenuBar / Menu / PopupMenu no idea what component are you using???
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);

      }      
      
}
dgofmanCommented:
You code is incomplete I cannot understand where is your dataProvider and what items you want to update?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Flex

From novice to tech pro — start learning today.