El caso es q estoy haciendo una aplicacion con struts y en la parte de la vista, en el jsp tengo que coger parametro pasado desde el cotrolador,
que es un array con valores que le tengo q pasar a javascript;
para que se lo pase al swf q esta embebido en la jsp. Esto se debe hacer cada vez que se presione un boton del swf, que es un teclado con las letras del abecedario.
pero no lo consigo, y de la siguiente manera q posteo a continuacion funciona a veces y otras no.
-En el JSP:
Código :
<script src="js/tecladoJSP.js"></script>
<%
String[] listaParam = (String[])request.getAttribute("valores");
%>
</head>
<body >
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
width="550" height="400" id="boton" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="flash/boton.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#333333" />
<embed src="flash/boton.swf" quality="high" bgcolor="#333333" width="550"
height="400" name="boton" align="middle" allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
<form name="htmlForm" method="POST" action="javascript:formSend();">
Sending to ActionScript:<br />
<input type="text" name="a" value="<%= listaParam[0]%>" /><br />
<input type="text" name="b" value="<%= listaParam[1]%>" /><br />
<input type="text" name="c" value="<%= listaParam[2]%>" /><br />
<input type="hidden" name="d" value="<%= listaParam[3]%>" /><br />
<input type="hidden" name="e" value="<%= listaParam[4]%>" /><br />
<input type="hidden" name="f" value="<%= listaParam[5]%>" /><br />
<input type="hidden" name="g" value="<%= listaParam[6]%>" /><br />
<input type="hidden" name="h" value="<%= listaParam[7]%>" /><br />
<input type="hidden" name="i" value="<%= listaParam[8]%>" /><br />
<input type="hidden" name="j" value="<%= listaParam[9]%>" /><br />
<input type="hidden" name="k" value="<%= listaParam[10]%>" /><br />
<input type="hidden" name="l" value="<%= listaParam[11]%>" /><br />
<input type="hidden" name="m" value="<%= listaParam[12]%>" /><br />
<input type="hidden" name="n" value="<%= listaParam[13]%>" /><br />
<input type="hidden" name="o" value="<%= listaParam[14]%>" /><br />
<input type="hidden" name="p" value="<%= listaParam[15]%>" /><br />
<input type="hidden" name="q" value="<%= listaParam[16]%>" /><br />
<input type="hidden" name="r" value="<%= listaParam[17]%>" /><br />
<input type="hidden" name="s" value="<%= listaParam[18]%>" /><br />
<input type="hidden" name="t" value="<%= listaParam[19]%>" /><br />
<input type="hidden" name="u" value="<%= listaParam[20]%>" /><br />
<input type="hidden" name="v" value="<%= listaParam[21]%>" /><br />
<input type="hidden" name="w" value="<%= listaParam[22]%>" /><br />
<input type="hidden" name="x" value="<%= listaParam[23]%>" /><br />
<input type="hidden" name="y" value="<%= listaParam[24]%>" /><br />
<input type="hidden" name="z" value="<%= listaParam[25]%>" /><br />
</form>
<form name="DynaLetra" method="post" action="pressLetra.do">
<input type="hidden" name="letra" />
</form>
[size=20][color=#EF2929]-En el js/tecladoJSP.js:[/color][/size]
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function formSend(letra) {
alert("letra recibida es"+letra);
DynaLetra.letra.value =letra;
document.DynaLetra.submit();
alert("vuelve del submit");
var list=new Array(26) ;
list[0]=document.htmlForm.a.value;
list[1]=document.htmlForm.b.value;
list[2]=document.htmlForm.c.value;
list[3]=document.htmlForm.d.value;
list[4]=document.htmlForm.e.value;
list[5]=document.htmlForm.f.value;
list[6]=document.htmlForm.g.value;
list[7]=document.htmlForm.h.value;
list[8]=document.htmlForm.i.value;
list[9]=document.htmlForm.j.value;
list[10]=document.htmlForm.k.value;
list[11]=document.htmlForm.l.value;
list[12]=document.htmlForm.m.value;
list[13]=document.htmlForm.n.value;
list[14]=document.htmlForm.o.value;
list[15]=document.htmlForm.p.value;
list[16]=document.htmlForm.q.value;
list[17]=document.htmlForm.r.value;
list[18]=document.htmlForm.s.value;
list[19]=document.htmlForm.t.value;
list[20]=document.htmlForm.u.value;
list[21]=document.htmlForm.v.value;
list[22]=document.htmlForm.w.value;
list[23]=document.htmlForm.x.value;
list[24]=document.htmlForm.y.value;
list[25]=document.htmlForm.z.value;
getFlashMovie("boton").flashFunc(list);
}
[size=20][color=][color=#EF2929]-En el flash:[/color][/color][/size]
import flash.external.*;
_root.a.a.addEventListener("click", clickSend);
_root.b.b.addEventListener("click", clickSend);
_root.c.c.addEventListener("click", clickSend);
_root.d.d.addEventListener("click", clickSend);
_root.e.e.addEventListener("click", clickSend);
_root.f.f.addEventListener("click", clickSend);
_root.g.g.addEventListener("click", clickSend);
_root.h.h.addEventListener("click", clickSend);
ExternalInterface.addCallback("flashFunc", this, clickSend);
function clickSend(evtObj:String) {
trace("The "+evtObj+" button was clicked");
_root.received_ti1.text = evtObj;
var jsArgument:String = evtObj;
var result:Object = ExternalInterface.call("formSend", jsArgument);
_root.received_ti2.text = "Returned: "+result;
_root.a.gotoAndStop(result[0]);
_root.b.gotoAndStop(result[1]);
_root.c.gotoAndStop(result[2]);
_root.d.gotoAndStop(result[3]);
_root.e.gotoAndStop(result[4]);
_root.f.gotoAndStop(result[5]);
_root.g.gotoAndStop(result[6]);
_root.h.gotoAndStop(result[7]);
_root.i.gotoAndStop(result[8]);
_root.j.gotoAndStop(result[9]);
}
