Forum de discussion
Forum « Flash et Shockwave » (archives)
Re: click droit et la classe ContextMenu
Envoyé: 14 mai 2004, 12h32 par Oznog
Oui, dada à raison, Flash permet maintenant la gestion du menu contextuel avec la nouvelle classe "ContextMenué"
Un minimum est d'enlever toute option sauf le "about Flash".
var myCustomMenu:ContextMenu = new ContextMenu();
myCustomMenu.hideBuiltInItems();
this.menu = myCustomMenu;
Mais ça ne sert à rien car tu peux le faire dasn la configuration de publication.
Tu as un très bon exemple complet ici : "Context Menus in Flash MX 2004" (http://www.actionscript.org/tutorials/intermediate/context_menu/index.shtml)
var lettersCM = new ContextMenu();//create object from the ContextMenu class
lettersCM.hideBuiltInItems();//hide the standard menu-items for that object
mcLetters.playing = false;//variable to track whether movie is playing or not
//-------------------------------
//called before menu is displayed
menuHandler = function (obj:Object, menu:ContextMenu){
if(obj.playing == true){
dance.visible = false;
if(noDance){
trace("noDance exists");
noDance.visible = true;
}else{
trace("create noDance");
//create a ContextMenuItem object
noDance = new ContextMenuItem("Stop Dancin!!!", stopDance);
//assign to ContextMenu.customItems array
lettersCM.customItems.push(noDance);
}
}else if(obj.playing == false){
noDance.visible = false;
if(dance){
trace("dance exists");
dance.visible = true;
}else{
trace("create dance");
dance = new ContextMenuItem("Dance Baby!!!", doDance);
lettersCM.customItems.push(dance);
}
}
}
//assign our function to the event handler
lettersCM.onSelect = menuHandler;
/****************************************/
function doDance() {
mcLetters.dancer.gotoAndPlay(2);
}
function stopDance() {
mcLetters.dancer.gotoAndStop(1);
}
//assign our ContextMenu object to the movieclip
mcLetters.menu = lettersCM;
Ciao
Oznog
Réponses
|