Voila le code simple pour t'aider
partie javascript :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
var Mouse_X;
var Mouse_Y;
function WhereMouse( e ){
var DocRef;
if( e){
Mouse_X = e.pageX;
Mouse_Y = e.pageY;
}
else{
Mouse_X = event.clientX;
Mouse_Y = event.clientY;
if( document.documentElement && document.documentElement.clientWidth)
DocRef = document.documentElement;
else
DocRef = document.body;
Mouse_X += DocRef.scrollLeft;
Mouse_Y += DocRef.scrollTop;
}
declencheFonctionActionScript();
}
document.onmousemove = WhereMouse;
function recupAnimation ( id ){
if (navigator.appName.indexOf("Microsoft") != -1)
return window[id];
else
return document[id];
}
function declencheFonctionActionScript ( ){
recupAnimation("monApplication").aliasFonction(Mouse_X,Mouse_Y);
} |
partie html :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <!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>Document sans nom</title>
<script type="text/javascript" src="script/mouse_see.js"></script>
</head>
<body>
<object width="550" height="400">
<param name="movie" value="test_external.swf" />
<param name="quality" value="high" />
<param name="allowScriptAccess" value="always" />
<embed src="test_external.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="550" height="400" allowscriptaccess="always" id="monApplication" name="monApplication" ></embed>
</object>
</body>
</html> |
partie flash
1 2 3 4 5 6 7 8 9
| var tf:TextField = new TextField();
addChild(tf);
ExternalInterface.addCallback ( 'aliasFonction', maFunction );
function maFunction ( x:int,y:int ):void
{
tf.text = 'x = '+x+', y = '+y;
} |
J'attire ton attention sur dans la partie html
allowscriptaccess="always" id="monApplication" name="monApplication"
ainsi que
<param name="allowScriptAccess" value="always" />
Indispensable pour les probleme de sécurité flash ainsi que pour le javascript (l'id et le name)
et voila le boulot !
Partager