Avatar of Jay Roy
Jay RoyFlag for United States of America

asked on 

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
Apache Flex

Avatar of undefined
Last Comment
dgofman
Avatar of dgofman
dgofman
Flag of United States of America image

Can you provide code of your implementation of MenuBar / Menu / PopupMenu no idea what component are you using???
Avatar of Jay Roy
Jay Roy
Flag of United States of America image

ASKER

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);

      }      
      
}
ASKER CERTIFIED SOLUTION
Avatar of dgofman
dgofman
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Apache Flex
Apache Flex

Apache Flex is a highly productive, open source application framework for building and maintaining expressive web applications that deploy consistently on all major browsers, desktops and devices (including smartphones, tablets and television). It provides a modern, standards-based language and programming model that supports common design patterns suitable for developers from many backgrounds. Flex applications can be deployed to the Adobe Player in the browser, Adobe AIR on desktop and mobile devices or to native Android, iOS, Windows or Mac applications.

4K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo