I am not exactly sure what you are trying to do. Are you trying to test the data Item to see if it is the root node of the tree?
What is the dataProvider? If it is xml, you could test for parent() == null. If it is nested collections then your connections would need to exponse a parent poperty. Of course, within an itemRender instance, as with any instance you can access public members through the dom properties, like parentDocument, and Application.application Tracy Spratt Lariat Services Flex development bandwidth available ________________________________ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Dan Vega Sent: Friday, January 09, 2009 3:50 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Custom Tree Item Renderer I have a custom tree item renderer that is working out great except one little small problem. In my item renderer I have some actions for adding / removing / renaming directories. The only time I don't want the remove or rename context menu items is when its the home directory. I know that I can hack it and hard code it here because the data object is passed to each function. What I am trying to do though is going back to the main part of the applicaiton (or pass in) the baseDirectory so I can account for change. Has anyone got data in/or out of a renderer before? If it was just another class it would be easy to put in the constructor but there is no constructor when you add it to the tree. **** itemRenderer="com.rocketfm.CustomTreeItemRenderer" package com.rocketfm { import flash.display.DisplayObject; import flash.events.ContextMenuEvent; import flash.ui.ContextMenu; import flash.ui.ContextMenuItem; import mx.collections.*; import mx.controls.treeClasses.*; import mx.core.Application; import mx.managers.PopUpManager; import views.AddDirectory; import views.DeleteDirectory; import views.RenameDirectory; public class CustomTreeItemRenderer extends TreeItemRenderer { private var renameWin:RenameDirectory; private var addWin:AddDirectory; private var delWin:DeleteDirectory; public function CustomTreeItemRenderer(basePath) { super(); var menu:ContextMenu = new ContextMenu(); var add:ContextMenuItem = new ContextMenuItem("Add Folder"); var remove:ContextMenuItem = new ContextMenuItem("Remove Folder"); var rename:ContextMenuItem = new ContextMenuItem("Rename Folder"); var download:ContextMenuItem = new ContextMenuItem("Download All"); add.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,addDirectory); remove.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,removeDirector y); rename.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,renameDirector y); menu.hideBuiltInItems(); menu.customItems.push(add); menu.customItems.push(remove); menu.customItems.push(rename); this.contextMenu = menu; } private function addDirectory(event:ContextMenuEvent):void { addWin = new AddDirectory(); addWin.dirPath = data.path; addWin.parentPath = data.parent; addWin.item = data; // add window PopUpManager.addPopUp(addWin,DisplayObject(Application.application),true ); } private function removeDirectory(event:ContextMenuEvent):void { delWin = new DeleteDirectory(); delWin.item = data; // delete window PopUpManager.addPopUp(delWin,DisplayObject(Application.application),true ); } private function renameDirectory(event:ContextMenuEvent):void { renameWin = new RenameDirectory(); renameWin.item = data; renameWin.oldDirectoryName = data.name; renameWin.parentPath = data.parent; // rename window PopUpManager.addPopUp(renameWin,DisplayObject(Application.application),t rue); } } } Thank You Dan Vega danv...@gmail.com <mailto:danv...@gmail.com> http://www.danvega.org <http://www.danvega.org>