将键盘和鼠标事件发送到Flash Movie [英] Send keyboard and mouse events to Flash Movie

查看:162
本文介绍了将键盘和鼠标事件发送到Flash Movie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来将某些事件注入到在浏览器上运行的Flash电影中。我知道ActionScript的ExternalInterface.addCallback函数,但是我试图通过网络上的任何随机闪存来实现此功能。例如。发送SPACE键盘事件到YouTube视频。

I'm looking for a way to "inject" some events into a flash movie running on a browser. I know about ActionScript's ExternalInterface.addCallback function, however I'm trying to achieve this with any "random" flash from the web. Eg. send a "SPACE" keyboard event to a youtube video.

推荐答案

您不能在任何网站上任意随机的swf由于安全限制。您需要访问DOM,只能通过 Javascript注入完成,除非你是嵌入在网站中的swf,否则在html模板中使用 allowScriptAccess =always。例如,MySpace允许您将任何随机swf添加到html页面,但是您不能执行该JavaScript的内容,因为它们强制执行 allowScriptAccess 始终为 false (除其他外),以​​防止任何javascript / dom访问。

You can't do this to any random swf on any website because of security limitations. You need to have access to the DOM, which can only be done by Javascript Injections, unless you are the one with the swf embedded in the site, with allowScriptAccess="always" in the html template. MySpace, for example, allows you to add any random swf to the html page, but you can't do that javascript stuff because they force allowScriptAccess to always be false (among other things) to prevent any javascript/dom access.

如果这只是为了让自己的生活更轻松浏览时,您可以使用 Firebug for Firefox 。查看这个JQuerify Bookmarklet和视频,使用Firebug和JQuery Hacking Digg / A>。它显示了如何使用javascript动态修改网页,并将这些命令保存为快捷方式!超级好。

If this is just for you to make your own life easier while browsing, you can use Firebug for Firefox. Check out this JQuerify Bookmarklet and Video, Hacking Digg with Firebug and JQuery. It shows you how to dynamically modify the webpage your on using javascript, and save those commands as shortcuts! Super cool.

所以你可以保存一个JQuerify命令,如:

So you could save a JQuerify command like:

$( #youtube_player)play();

...或者在其html页面中启动YouTube视频的任何api,如果这是可能的话。

...or whatever the api is for starting a youtube video in their html page, if that's even possible.

希望有帮助,
Lance

Hope that helps, Lance

这篇关于将键盘和鼠标事件发送到Flash Movie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆