编程题:编写一个函数string_copy()完成strcpy()的作用,并验证。
2014-05-19 18:18
459 查看
今天偶然想做FLEX里鼠标右键弹出菜单,但其实是很麻烦的,因为忘记了FLASH自己是有个鼠标右键菜单的,所以还是不动为秒,
但如果实在要动的话,也可以,转载之:
1.如果你是Desktop Application
监听事件的MouseEvent.RIGHT_CLICK事件
比如对某个控件a进行监控右键点击事件
a.addEventListener(MouseEvent.RIGHT_CLICK,func);
鼠标的其他事件也可以监听,具体见http://livedocs.adobe.com/flex/3_cn/langref/flash/events/MouseEvent.html
2.如果是Web Appliction(麻烦了!)
其基本思路为:
1,在FLEX中利用外部接口注册一个函数, 作为接收外部(HTML)右键事件的入口
2,在FLEX应用所在的HTML中拦截鼠标右键事件,调用FLEX外部函数,并取消事件的广播,以阻止事件到达FLEX应用.
3,在FLEX应用程序上监听mouseOver事件,并记录当前鼠标所在对象
4,当入口函数接收到HTML发送的右键事件后,模拟生成一个鼠标右键事件(buttonDown = false), 并发送到当前对象
5,在对象的mouseDown处理函数中,根据buttonDown的标志,分别处理鼠标左右键事件
这个思路比较清晰可行, 鼠标右键事件的流程为:
HTML鼠标右键事件----FLEX外部函数-----模拟的鼠标右键事件------相应的处理函数
具体的实现为:
1, 在FLEX所在的HTML增加
<script>
function onNsRightClick(e){
if(e.which == 3){
FlexTest.openRightClick();
e.stopPropagation();
}
return false;
}
function onIeRightClick(e){
if(event.button > 1){
FlexTest.openRightClick();
parent.frames.location.replace('javascript: parent.falseframe');
}
return false;
}
if(navigator.appName == "Netscape"){
document.captureEvents(Event.MOUSEDOWN);
document.addEventListener("mousedown", onNsRightClick, true);
}
else{
document.
}
</script>
2, 修改FLEX的MXML
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()" mouseOver="getMouseTarget(event)" >
private var mouseTarget:DisplayObject;
function init()
{
ExternalInterface.addCallback("openRightClick", openRightClick);
}
function getMouseTarget(event:MenuEvent):void
{
mouseTarget = DisplayObject(event.target);
}
function openRightClick():void
{
var e:MouseEvent = new MouseEvent(MouseEvent.MOUSE_DOWN, true, false, mouseTarget.mouseX, mouseTarget.mouseY);
mouseTarget.dispatchEvent(e);
}
function showMouseEvent(event)
{
if(event.buttonDown == true)
Alert.show("Left");
else
Alert.show("Right");
}
<mx:Image x="0" y="10" id="bbb" name="bbb" source="res/15.jpg" mouseDown="showMouseEvent(event)" height="247"/>
在修改完后,满怀信心的进行测试,结果右键菜单还能够出现!试了很多办法也不行,幸亏我的同事赵辉发现了解决方法,在这里向他表示感谢!
具体的方法就是修改wmode参数, 将wmode设置为opaque或transparent都可以达到这个效果
AC_FL_RunContent(
"src", "playerProductInstall",
"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
"width", "100%",
"height", "100%",
"align", "middle",
"id", "FlexTest",
"wmode", "opaque", //////////////////////注意:这里是关键
"quality", "high",
"bgcolor", "#869ca7",
"name", "FlexTest",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
ADOBE文档中对wmode的解释:
Sets the Window Mode property of the SWF file for transparency, layering, and positioning in the browser. Valid values of wmode are window, opaque, and transparent.
Set to window to play the SWF in its own rectangular window on a web page.
Set to opaque to hide everything on the page behind it.
Set to transparent so that the background of the HTML page shows through all transparent portions of the SWF file. This can slow animation performance.
To make sections of your SWF file transparent, you must set the alpha property to 0. To make your application's background transparent, set the alpha property on the <mx:Application> tag to 0.
The wmode property is not supported in all browsers and platforms.
但如果实在要动的话,也可以,转载之:
1.如果你是Desktop Application
监听事件的MouseEvent.RIGHT_CLICK事件
比如对某个控件a进行监控右键点击事件
a.addEventListener(MouseEvent.RIGHT_CLICK,func);
鼠标的其他事件也可以监听,具体见http://livedocs.adobe.com/flex/3_cn/langref/flash/events/MouseEvent.html
2.如果是Web Appliction(麻烦了!)
其基本思路为:
1,在FLEX中利用外部接口注册一个函数, 作为接收外部(HTML)右键事件的入口
2,在FLEX应用所在的HTML中拦截鼠标右键事件,调用FLEX外部函数,并取消事件的广播,以阻止事件到达FLEX应用.
3,在FLEX应用程序上监听mouseOver事件,并记录当前鼠标所在对象
4,当入口函数接收到HTML发送的右键事件后,模拟生成一个鼠标右键事件(buttonDown = false), 并发送到当前对象
5,在对象的mouseDown处理函数中,根据buttonDown的标志,分别处理鼠标左右键事件
这个思路比较清晰可行, 鼠标右键事件的流程为:
HTML鼠标右键事件----FLEX外部函数-----模拟的鼠标右键事件------相应的处理函数
具体的实现为:
1, 在FLEX所在的HTML增加
<script>
function onNsRightClick(e){
if(e.which == 3){
FlexTest.openRightClick();
e.stopPropagation();
}
return false;
}
function onIeRightClick(e){
if(event.button > 1){
FlexTest.openRightClick();
parent.frames.location.replace('javascript: parent.falseframe');
}
return false;
}
if(navigator.appName == "Netscape"){
document.captureEvents(Event.MOUSEDOWN);
document.addEventListener("mousedown", onNsRightClick, true);
}
else{
document.
}
</script>
2, 修改FLEX的MXML
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()" mouseOver="getMouseTarget(event)" >
private var mouseTarget:DisplayObject;
function init()
{
ExternalInterface.addCallback("openRightClick", openRightClick);
}
function getMouseTarget(event:MenuEvent):void
{
mouseTarget = DisplayObject(event.target);
}
function openRightClick():void
{
var e:MouseEvent = new MouseEvent(MouseEvent.MOUSE_DOWN, true, false, mouseTarget.mouseX, mouseTarget.mouseY);
mouseTarget.dispatchEvent(e);
}
function showMouseEvent(event)
{
if(event.buttonDown == true)
Alert.show("Left");
else
Alert.show("Right");
}
<mx:Image x="0" y="10" id="bbb" name="bbb" source="res/15.jpg" mouseDown="showMouseEvent(event)" height="247"/>
在修改完后,满怀信心的进行测试,结果右键菜单还能够出现!试了很多办法也不行,幸亏我的同事赵辉发现了解决方法,在这里向他表示感谢!
具体的方法就是修改wmode参数, 将wmode设置为opaque或transparent都可以达到这个效果
AC_FL_RunContent(
"src", "playerProductInstall",
"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
"width", "100%",
"height", "100%",
"align", "middle",
"id", "FlexTest",
"wmode", "opaque", //////////////////////注意:这里是关键
"quality", "high",
"bgcolor", "#869ca7",
"name", "FlexTest",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
ADOBE文档中对wmode的解释:
Sets the Window Mode property of the SWF file for transparency, layering, and positioning in the browser. Valid values of wmode are window, opaque, and transparent.
Set to window to play the SWF in its own rectangular window on a web page.
Set to opaque to hide everything on the page behind it.
Set to transparent so that the background of the HTML page shows through all transparent portions of the SWF file. This can slow animation performance.
To make sections of your SWF file transparent, you must set the alpha property to 0. To make your application's background transparent, set the alpha property on the <mx:Application> tag to 0.
The wmode property is not supported in all browsers and platforms.
相关文章推荐
- sql语句 自己编写一个函数reversion,完成颠倒一个字符串,即:select dbo.reversion('abcd') 输出的结果为 dcba
- 编写程序,分离出一个实数的整数部分与小数部分,要求用函数完成
- 编写一个函数reverse_string(char * string)(递归实现) 实现:将参数字符串中的字符反向排列。
- 客户端验证函数,作用:例如判定复选框必须至少有一个被选中才可以提交
- C语言 编写一个函数reverse_string(char * string) 实现:将参数字符串中的字符反向排列。
- 【C语言】编写一个函数reverse_string(char * string) 实现:将参数字符串中的字符反向排列。要求:不能使用C函数库中的字符串操作函数。
- 编写一个函数,有两个参数function(string s1,string s2),找出字符串中s1中s2的个数
- 编写一个函数reverse_string(char *string),递归实现
- 编写一个函数reverse_string(char * string)(递归实现)
- 编写一个名为my_strcpy_end的函数, 他返回一个指向目标字符串末尾的指针 (也就是说指向NUL字节的指针)
- 请编写一个JavaScript 函数toRGB,它的作用是转换CSS中常用的颜色编码
- 编写一个类,该类具有统计文件长度,实现文件复制的函数。 其中复制功能函数如: void copy(string srcFileName,string targetFileName);
- 编写一个函数reverse_string(char * string) 实现:将参数字符串中的字符反向排列。
- 编写一个函数,作用是把一个char组成的字符串循环右移n个。比如原来是“abcdefghi”如果n=2,移位后应该是“hiabcdefgh”
- 编写一个函数,作用是把一个char组成的字符串循环右移n个
- 关于《程序员编程宝典》中编写一个函数,作用是把一个char组成的字符串循环右移n位的问题
- 编写一个函数,作用是把一个char组成的字符串循环右移n个。比如原来是“abcdefghi”如果n=2,移位后应该是“hiabcdefgh”
- 用c语言实现 编写一个函数reverse_string(char * string)
- 【c语言】编写一个函数reverse_string(char * string) 实现:将参数字符串中的字符反向排列。 要求:不能使用C函数库中的字符串操作函数