|
I have created sample context menu which consist of 2 items.Below
is the code for that. If you will run this you will find a canvas in red color and
if you right click you will find context menu with two items “Split Canvas”
and “Split Again”. Now if you will select split Canvas then that Red canvas
will get splited into two new child canvas. Now if user again select split
again I want to split the child canvas into two new children. This
is what I want to do I am getting the id of
child canvas when user clicks on the child. Can anybody suggest some solution on this
please help………………… <?xml version="1.0"
encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:myp="uiMyContext.*" xmlns:local="*"
creationComplete="ContextMenuItemExample1();"> <mx:Canvas
id="baseCanvas" width="50%" height="50%"
backgroundColor="Red"/> <mx:Script> <![CDATA[ import
mx.containers.HDividedBox; import
mx.containers.Canvas; import
mx.events.MenuEvent; import
uiMyContext.ContextMenuExample; import
flash.ui.ContextMenu; import
flash.ui.ContextMenuItem; import
flash.ui.ContextMenuBuiltInItems; import
mx.controls.TextArea; import
mx.controls.Text; import
mx.controls.Alert; import
flash.events.*; import
flash.display.Sprite; import
flash.display.Shape; import
flash.text.TextField; public var
myContextMenu:ContextMenu; public function
ContextMenuItemExample1():void {
myContextMenu = new ContextMenu();
removeDefaultItems();
addCustomMenuItems();
baseCanvas.contextMenu = myContextMenu; } private function
removeDefaultItems():void {
myContextMenu.hideBuiltInItems();
var defaultItems:ContextMenuBuiltInItems = myContextMenu.builtInItems;
defaultItems.print = true; } private function
addCustomMenuItems():void {
var item:ContextMenuItem = new ContextMenuItem("Split Canvas"); item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,clickMe); var
item1:ContextMenuItem = new ContextMenuItem("Split Canvas Again"); item1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,splitAgain);
myContextMenu.customItems.push(item1,item); } public function
splitAgain(e:ContextMenuEvent):void {
Alert.show(String(e.currentTarget));
} public function
clickMe(e:ContextMenuEvent):void { var
hDivide:HDividedBox=new HDividedBox(); hDivide.percentHeight=100; hDivide.percentWidth=100; hDivide.setStyle("backgroundColor","white"); var
child1:Canvas=new Canvas(); child1=createChildCan(); child1.setStyle("backgroundColor","#ffecec") var
child2:Canvas=new Canvas(); child2=createChildCan(); child2.setStyle("backgroundColor","#808080") var
child3:Canvas=new Canvas(); child3=createChildCan(); child3.setStyle("backgroundColor","#ffecec") hDivide.addChild(child1); hDivide.addChild(child2); baseCanvas.addChild(hDivide); } public function
createChildCan():Canvas { var
childCan:Canvas=new Canvas(); childCan.percentHeight=100; childCan.percentWidth=100; childCan.addEventListener(MouseEvent.CLICK,getID) return
childCan; } public function
getID(event:MouseEvent):void { Alert.show(String(event.currentTarget)); } ]]> </mx:Script> </mx:Application> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS
__,_._,___ |
- [flexcoders] Capture object on Right Click Kumar
- Re: [flexcoders] Capture object on Right Click Abdul Qabiz

