Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flash 使用带Dijit.Menu的ZeroClipboard提供复制功能_Flash_Copy_Dojo_Zeroclipboard - Fatal编程技术网

Flash 使用带Dijit.Menu的ZeroClipboard提供复制功能

Flash 使用带Dijit.Menu的ZeroClipboard提供复制功能,flash,copy,dojo,zeroclipboard,Flash,Copy,Dojo,Zeroclipboard,我有一个webapp,它允许通过右键单击使用zeroClipboard、Dijit.菜单复制文本。问题是Flash 10需要用户点击实际的Flash小程序,以便现在就可以实现 我曾尝试使用ZeroClipboard.glue()方法将swf“粘合”到菜单项,但没有成功。我只是想知道是否有人不得不处理这个问题 谢谢。我想出了一个解决方案,它并不漂亮,因为当鼠标悬停在菜单上方时,菜单标题将消失,但至少它可以工作。我还没有进行过广泛的测试,但我希望它不会泄漏flash对象 <!DOCTY

我有一个webapp,它允许通过右键单击使用zeroClipboard、Dijit.菜单复制文本。问题是Flash 10需要用户点击实际的Flash小程序,以便现在就可以实现

我曾尝试使用ZeroClipboard.glue()方法将swf“粘合”到菜单项,但没有成功。我只是想知道是否有人不得不处理这个问题


谢谢。

我想出了一个解决方案,它并不漂亮,因为当鼠标悬停在菜单上方时,菜单标题将消失,但至少它可以工作。我还没有进行过广泛的测试,但我希望它不会泄漏flash对象

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>ZeroClipboard Menu Demo</title>
    <style type="text/css">
        @import "http://o.aolcdn.com/dojo/1.0.0/dijit/themes/tundra/tundra.css";
        @import "http://o.aolcdn.com/dojo/1.0.0/dojo/resources/dojo.css";
    </style>
    <script type="text/javascript" src="js/ZeroClipboard.js"></script>
    <script type="text/javascript" src="js/dojo/dojo.js"
            djConfig="parseOnLoad:true, isDebug:false, preventBackButtonFix: true"></script>
    <script type="text/javascript">
        dojo.require("dojo.parser");
        dojo.require("dijit.Menu");
        ZeroClipboard.setMoviePath('flash/ZeroClipboard.swf');
    </script>
</head>
<body class="tundra">


<div id="MenuTarget">Right Click Here</div>

<script type="text/javascript">
    var menu = new dijit.Menu();

    var menuItem1 = new dijit.MenuItem({
        id: "tester",
        label: "This Does Nothing",
        parentMenu: menu
    });

    menu.addChild(menuItem1);
    menu.bindDomNode(dojo.byId("MenuTarget"));

    var menuItem2 = new dijit.MenuItem({
        id: "tester2",
        label: "Copy Some Text",
        parentMenu: menu
    });

    attachCopyEvent(menuItem2, "Some Text");
    menu.addChild(menuItem2);

    /*
     attaches ZeroClipboard object to specified menu item
     menuItem: diji.menuItem to attach to
     copyText: text to copy to clipboard
     */
    function attachCopyEvent(menuItem, copyText) {
        var myId = menuItem.domNode.id;
        var origText = menuItem.label;    //Grab the original menu caption
        var clip;  //keep the clip object external/public to the connecdt functions

        //Replace the text of the menuItem with the flash object when the mouse hovers over it
        //We use the connect method of the menuitem so that the connects are destroyed when the object is destroyed
        menuItem.connect(menuItem, "_onHover", function() {
            var myLabelDiv = dojo.byId(myId + "_text"); //The label for menuItems is always the id of the menu item with '_text' appended
            clip = new ZeroClipboard.Client();
            //Destroy the flash object when copy is complted to save RAM
            clip.addEventListener('onComplete', function() {
                clip.destroy();
            });
            //Grab the size of the div and tell zeroclipboard to generate embed html of neccesary size
            clip.setText(copyText);
            myLabelDiv.innerHTML = clip.getHTML(myLabelDiv.clientWidth - 5, myLabelDiv.clientHeight - 6);
        });

        menuItem.connect(menuItem, "_onUnhover", function() {
            var myLabelDiv = dojo.byId(myId + "_text"); //The label for menuItems is always the id of the menu item with '_text' appended
            myLabelDiv.innerHTML = origText;
            clip.destroy();
        });
    }

</script>

</body>
</html>

零剪贴板菜单演示
@进口”http://o.aolcdn.com/dojo/1.0.0/dijit/themes/tundra/tundra.css";
@进口”http://o.aolcdn.com/dojo/1.0.0/dojo/resources/dojo.css";
require(“dojo.parser”);
dojo.require(“dijit.Menu”);
ZeroClipboard.setMoviePath('flash/ZeroClipboard.swf');
右击此处
var menu=new dijit.menu();
var menuItem1=新的dijit.MenuItem({
id:“测试人员”,
标签:“这不起任何作用”,
父菜单:菜单
});
menu.addChild(menuItem1);
menu.bindDomNode(dojo.byId(“MenuTarget”);
var menuItem2=新的dijit.MenuItem({
id:“tester2”,
标签:“复制一些文本”,
父菜单:菜单
});
attachCopyEvent(menuItem2,“一些文本”);
menu.addChild(menuItem2);
/*
将剪贴板对象附加到指定的菜单项
menuItem:diji.menuItem要附加到
copyText:要复制到剪贴板的文本
*/
函数attachCopyEvent(menuItem、copyText){
var myId=menuItem.domNode.id;
var origText=menuItem.label;//获取原始菜单标题
var clip;//保持clip对象在connecdt函数外部/公共
//当鼠标悬停在菜单项上时,将其文本替换为flash对象
//我们使用menuitem的connect方法,以便在对象被销毁时销毁连接
连接(menuItem,“\u onHover”,函数(){
var myLabelDiv=dojo.byId(myId+“_text”);//菜单项的标签始终是附加了“_text”的菜单项的id
clip=新的ZeroClipboard.Client();
//完成复制以保存RAM时销毁闪存对象
clip.addEventListener('onComplete',function(){
clip.destroy();
});
//获取div的大小并告诉zeroclipboard生成必要大小的嵌入html
clip.setText(copyText);
myLabelDiv.innerHTML=clip.getHTML(myLabelDiv.clientWidth-5,myLabelDiv.clientHeight-6);
});
连接(menuItem,“\u onUnhover”,函数(){
var myLabelDiv=dojo.byId(myId+“_text”);//菜单项的标签始终是附加了“_text”的菜单项的id
myLabelDiv.innerHTML=origText;
clip.destroy();
});
}

我想出了一个解决方案,它并不漂亮,因为当鼠标悬停在菜单标题上方时,菜单标题将消失,但至少它可以工作。我还没有进行过广泛的测试,但我希望它不会泄漏flash对象

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>ZeroClipboard Menu Demo</title>
    <style type="text/css">
        @import "http://o.aolcdn.com/dojo/1.0.0/dijit/themes/tundra/tundra.css";
        @import "http://o.aolcdn.com/dojo/1.0.0/dojo/resources/dojo.css";
    </style>
    <script type="text/javascript" src="js/ZeroClipboard.js"></script>
    <script type="text/javascript" src="js/dojo/dojo.js"
            djConfig="parseOnLoad:true, isDebug:false, preventBackButtonFix: true"></script>
    <script type="text/javascript">
        dojo.require("dojo.parser");
        dojo.require("dijit.Menu");
        ZeroClipboard.setMoviePath('flash/ZeroClipboard.swf');
    </script>
</head>
<body class="tundra">


<div id="MenuTarget">Right Click Here</div>

<script type="text/javascript">
    var menu = new dijit.Menu();

    var menuItem1 = new dijit.MenuItem({
        id: "tester",
        label: "This Does Nothing",
        parentMenu: menu
    });

    menu.addChild(menuItem1);
    menu.bindDomNode(dojo.byId("MenuTarget"));

    var menuItem2 = new dijit.MenuItem({
        id: "tester2",
        label: "Copy Some Text",
        parentMenu: menu
    });

    attachCopyEvent(menuItem2, "Some Text");
    menu.addChild(menuItem2);

    /*
     attaches ZeroClipboard object to specified menu item
     menuItem: diji.menuItem to attach to
     copyText: text to copy to clipboard
     */
    function attachCopyEvent(menuItem, copyText) {
        var myId = menuItem.domNode.id;
        var origText = menuItem.label;    //Grab the original menu caption
        var clip;  //keep the clip object external/public to the connecdt functions

        //Replace the text of the menuItem with the flash object when the mouse hovers over it
        //We use the connect method of the menuitem so that the connects are destroyed when the object is destroyed
        menuItem.connect(menuItem, "_onHover", function() {
            var myLabelDiv = dojo.byId(myId + "_text"); //The label for menuItems is always the id of the menu item with '_text' appended
            clip = new ZeroClipboard.Client();
            //Destroy the flash object when copy is complted to save RAM
            clip.addEventListener('onComplete', function() {
                clip.destroy();
            });
            //Grab the size of the div and tell zeroclipboard to generate embed html of neccesary size
            clip.setText(copyText);
            myLabelDiv.innerHTML = clip.getHTML(myLabelDiv.clientWidth - 5, myLabelDiv.clientHeight - 6);
        });

        menuItem.connect(menuItem, "_onUnhover", function() {
            var myLabelDiv = dojo.byId(myId + "_text"); //The label for menuItems is always the id of the menu item with '_text' appended
            myLabelDiv.innerHTML = origText;
            clip.destroy();
        });
    }

</script>

</body>
</html>

零剪贴板菜单演示
@进口”http://o.aolcdn.com/dojo/1.0.0/dijit/themes/tundra/tundra.css";
@进口”http://o.aolcdn.com/dojo/1.0.0/dojo/resources/dojo.css";
require(“dojo.parser”);
dojo.require(“dijit.Menu”);
ZeroClipboard.setMoviePath('flash/ZeroClipboard.swf');
右击此处
var menu=new dijit.menu();
var menuItem1=新的dijit.MenuItem({
id:“测试人员”,
标签:“这不起任何作用”,
父菜单:菜单
});
menu.addChild(menuItem1);
menu.bindDomNode(dojo.byId(“MenuTarget”);
var menuItem2=新的dijit.MenuItem({
id:“tester2”,
标签:“复制一些文本”,
父菜单:菜单
});
attachCopyEvent(menuItem2,“一些文本”);
menu.addChild(menuItem2);
/*
将剪贴板对象附加到指定的菜单项
menuItem:diji.menuItem要附加到
copyText:要复制到剪贴板的文本
*/
函数attachCopyEvent(menuItem、copyText){
var myId=menuItem.domNode.id;
var origText=menuItem.label;//获取原始菜单标题
var clip;//保持clip对象在connecdt函数外部/公共
//当鼠标悬停在菜单项上时,将其文本替换为flash对象
//我们使用menuitem的connect方法,以便在对象被销毁时销毁连接
连接(menuItem,“\u onHover”,函数(){
var myLabelDiv=dojo.byId(myId+“_text”);//菜单项的标签始终是附加了“_text”的菜单项的id
clip=新的ZeroClipboard.Client();
//完成复制以保存RAM时销毁闪存对象
clip.addEventListener('onComplete',function(){
clip.destroy();
});
//获取div的大小并告诉zeroclipboard生成必要大小的嵌入html
clip.setText(copyText);
myLabelDiv.innerHTML=clip.getHTML(myLabelDiv.clientWidth-5,myLabelDiv.clientHeight-6);
});
连接(menuItem,“\u onUnhover”,函数(){
var myLabelDiv=dojo.byId(myId+“_text”);//菜单项的标签始终是附加了“_text”的菜单项的id
myLabelDiv.innerHTML=origText;
clip.destroy();
});
}