
August 12th, 2010, 11:34 AM
|
|
Registered User
|
|
Join Date: Aug 2010
Posts: 1
Time spent in forums: 23 m 6 sec
Reputation Power: 0
|
|
Iphone safari drag and drop flash
Hi
I am creating an iphone webapp with html so that you will be able to play flash games with the latest frash 0.2, and whenever i go to aflash game on mobilesafari thats needs drag and drop, when i drag on the .swf, it scrolls the page however when i drag elsewhere, it doesnt drag. i would like to make it so that when i drag on the flash game it doesnt scroll
the javascript code im trying to use to disable scrolling is:
<script type="text/javascript">
function touchHandler(event)
{
var touches = event.changedTouches,
first = touches[0],
type = "";
switch(event.type)
{
case "touchstart":
type = "mousedown";
break;
case "touchmove":
type="mousemove";
event.preventDefault();
break;
case "touchend":
type="mouseup";
break;
default:
return;
}
var simulatedEvent = document.createEvent("MouseEvent");
//initMouseEvent(type, canBubble, cancelable, view, clickCount, screenX, screenY, clientX, clientY,
// ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);
simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
false, false, false, false, 0/*left*/, null);
first.target.dispatchEvent(simulatedEvent);
//event.preventDefault();
}
function init()
{
document.addEventListener("touchstart", touchHandler, false);
document.addEventListener("touchmove", touchHandler, false);
document.addEventListener("touchend", touchHandler, false);
document.addEventListener("touchcancel", touchHandler, false);
}
</script>
<script charset="utf-8" id="injection_graph_func" src="iphone_files/injection_graph_func.js"></script></head><body onload="init();">
<script type="text/javascript" src="iphone_files/jquery-1.js"></script>
<script type="text/javascript" src="iphone_files/jquery_002.js"></script>
<script type="text/javascript" src="iphone_files/jquery.js">
</script>
Is there a way to make this code target towards the flash object and enable clicking on the flash game?
|