[英]Click coordinates on canvas no longer match mouse after keydown simulated click
[英]Add simulated left mouse click after page loads swf object
我已将Flash游戏添加到我的网站,由于某种原因,加载后需要在页面上的任意位置单击鼠标左键。 然后单击使箭头键起作用。
我已经尝试在html中使用基于js的鼠标触发器,并向我的Flash对象添加了一个id,但是它仍然无法正常工作。 有什么建议吗?
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Donkey Kong</title>
<script type="text/javascript">
function swfLoadEvent(fn){
//Ensure fn is a valid function
if(typeof fn !== "function"){ return false; }
//This timeout ensures we don't try to access PercentLoaded too soon
var initialTimeout = setTimeout(function (){
//Ensure Flash Player's PercentLoaded method is available and returns a value
if(typeof e.ref.PercentLoaded !== "undefined" && e.ref.PercentLoaded()){
//Set up a timer to periodically check value of PercentLoaded
var loadCheckInterval = setInterval(function (){
//Once value == 100 (fully loaded) we can do whatever we want
if(e.ref.PercentLoaded() === 100){
//Execute function
fn();
//Clear timer
clearInterval(loadCheckInterval);
}
}, 1500);
}
}, 200);
}
</script>
<script type="text/javascript">
$("document").ready(function() {
setTimeout(function() {
$("#swf").trigger('click');
},5000);
});
</script>
</head>
<style type="text/css">
body, html{
height: 100%;
min-height: 100%;
}
body
{
border: 0px;
padding: 0px;
overflow: hidden;
margin: 0px;
}
object {
border: none;
outline: none;
}
</style>
<body style="background-color: #000000">
<table class="flash-container" style="height: 94%; width:100%">
<tr style="height: 100%; width:100%">
<td style="height: 100%; width:100%">
<script type="text/javascript">
//This function is invoked by SWFObject once the <object> has been created
var callback = function (e){
//Only execute if SWFObject embed was successful
if(!e.success || !e.ref){ return false; }
swfLoadEvent(function(){
alert("The SWF has finished loading!");
});
};
swfobject.embedSWF("donkey_kong.swf", "flashcontent", "550", "400", "9", false, false, false, false, callback);
</script>
</td>
</tr>
</table>
</body>
</html>
您需要轮询100%加载的Flash对象。 在此处检查解决方案:
http://learnswfobject.com/advanced-topics/executing-javascript-when-the-swf-has-finished-loading/
编辑:您当前的函数中有HTML。 删除HTML,如下所示:
swfLoadEvent(function(){
alert("The SWF has finished loading!");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.