This content has been marked as final. Show 9 replies
How to set right click functionality in adobe flex 2....
Simply whenever we run a MXML we got setting , print and about flash player ......
I want to set some other function ,,,,,,,,,,, Please help me Wink
dear i want to set cut , copy ,paste , undo , redo option on right click , mean to say if user is right clicking of mouse use will get the option okay . is it possible in flex
please help me
Yes. Context menu, that's right click, is avaialable in Flex. However, copy, paste, undo, redo... are not built-in. As a matter of these strings aren't allowed in the as context menu titles "Paste rows" is allowed while "Paste" is NOT allowed as a title.
Context menus are available only for the "top level" components: components that are directly inside <application> tag.
You would need to build all these functionalities all by yourself!
Excerpt from the FB 2 help on contextMenu:
The ContextMenu class provides control over the items in the Flash Player context menu. You can add custom menu items, control the display of the built-in context menu items (for example, Zoom In and Print), or create copies of menus.
You can attach a ContextMenu object to a specific button, movie clip, or text field object, or to an entire movie level. You use the menu property of the Button, MovieClip, or TextField class to do this.
In Flex, only top-level components in the application can have context menus. For example, if a DataGrid control is a child of a TabNavigator or VBox container, the DataGrid control cannot have its own context menu.
To add new items to a ContextMenu object, you create a ContextMenuItem object, and then add that object to the ContextMenu.customItems array.
Flash Player has three types of context menus, but only the standard and edit menus can be modified with the ContextMenu class.:
- the standard menu (which appears when you right-click in Flash Player)
- the edit menu (which appears when you right-click a selectable or editable text field)
- error menu (which appears when a SWF file has failed to load into Flash Player).
Custom menu items always appear at the top of the Flash Player context menu, above any visible built-in menu items; a separator bar distinguishes built-in and custom menu items. You can add no more than 15 custom items to a context menu. You cannot remove the Settings menu item from the context menu. The Settings menu item is required in Flash so that users can access the settings that affect privacy and storage on their computers. You also cannot remove the About menu item, which is required so that users can find out what version of Flash Player they are using.
You must use the ContextMenu() constructor to create a ContextMenu object before calling its methods.
suppose i have a image then when we rightclick on the image i set cut copy paste undo & redo in context menu
then how do i cut an image and paste it on another place
// WITHIN THE SCRIPT TAGS OF THE MAIN MXML
// Context menu
private var applicationContextMenu:ContextMenu = new ContextMenu();
private function removeDefaultItems():void
var defaultItems:ContextMenuBuiltInItems = applicationContextMenu.builtInItems;
defaultItems.print = true;
private function addCustomMenuItems(label:String, fcn:Function, separator:Boolean):void
var item:ContextMenuItem = new ContextMenuItem(label);
item.separatorBefore = separator;
// IN THE CREATION COMPLETE METHOD OF THE MAIN MXML
addCustomMenuItems("Cut", this.onCut, true);
addCustomMenuItems("Copy", this.onCopy, false);
addCustomMenuItems("Paste", this.onPaste, false);
this.contextMenu = applicationContextMenu;
// Where onCut, onCopy and onPaste are the event handlers for your custom context menu items, Cut , Copy and Paste respectively.
private function onCut(event:ContextMenuEvent):void
// Implement the Cut functionnality here
private function onCopy(event:ContextMenuEvent):void
// Implement the Copy functionnality here
private function onPaste(event:ContextMenuEvent):void
// Implement the Paste functionnality here
I know all this . If you have seen scrapblog.com , in this website when we create a new scrap we put some object
like square, rectangle etc then scrapblog is giving facilities of cut , paste , undo on the particular square, rectangle
in this way user can cut, paste the object as well as undo & redo the work .. I am giving same functionalities in my application
so how do it possible . in setclipboard method u can take only string not any object .... is there any solution
please help me