this works, ignore the rest of the stuff
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute" 
creationComplete="initApp()">
<mx:Script>
<![CDATA[
private function initApp():void{
var customContextMenu:ContextMenu = new ContextMenu();
var customItem:ContextMenuItem = new ContextMenuItem("Show Me",false,true,true);
customContextMenu.customItems.push(customItem);
customContextMenu.hideBuiltInItems();
customItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,showMeStuff);
contextMenu=customContextMenu;
}
private function showMeStuff(event:ContextMenuEvent):void{
if(ContextMenuItem(event.target).caption=="Show Me"){
ContextMenuItem(event.target).caption="Hide Me" 
}else{
ContextMenuItem(event.target).caption="Show Me"
}
}
]]>
</mx:Script>
<mx:Style>
global{
backgroundAlpha :0;
fontSize:14;
fontFamily:'Arial';
}
</mx:Style>
<mx:Panel title="Chapter 1-Solution 1.2" width="261" height="178" id="myPanel">
<mx:Label text="This is a dummy Text" />
</mx:Panel>
</mx:Application>



----- Original Message ----
From: srikanth_reddy_007 <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, January 23, 2008 11:51:21 PM
Subject: [flexcoders] Contest menu text doesn't change if i set the caption 
property


Code snippet:

var statusBarItem: ContextMenuItem = new ContextMenuItem( "show me",
false, true, true);
showMeItem.addEvent Listener( ContextMenuEvent. MENU_ITEM_ SELECT,
showMeListener );
cm.customItems. push(showMeItem) ;
Context menu doesn't change the label if it reset the caption
property. it shows me the label what i have set ate the begining only.
can some body help!!!

public function showMeListener( event:ContextMen uEvent):void {

var statusBarItem: ContextMenuItem = ContextMenuItem( event.currentTar get);

var statusCaption: String = "";

if(ModelLocator. getInstance( ).xyzModel. showMe == true) {
ModelLocator. getInstance( ).visualizerMode l.showME = false;
statusCaption = "Hide me";
} else {
ModelLocator. getInstance( ).visualizerMode l.showME = true;
statusCaption = "Show me";
}
statusBarItem. caption = statusCaption;
}

but my context menu caption is not changing from "Show me" to "Hide
me" and vice versa.





      
____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

Reply via email to