Foros del Web » Creando para Internet » Flash y Actionscript »

Llamar a JavaScript desde Flash

Estas en el tema de Llamar a JavaScript desde Flash en el foro de Flash y Actionscript en Foros del Web. Tengo un botón con la siguiente acción asignada: Código: on(rollOver) { mostrar('liderar'); } on(rollOut) { ocultar('liderar'); } Y en un frame tengo declaradas las funciones ...
  #1 (permalink)  
Antiguo 09/01/2006, 14:27
 
Fecha de Ingreso: febrero-2005
Mensajes: 670
Antigüedad: 19 años, 2 meses
Puntos: 0
Llamar a JavaScript desde Flash

Tengo un botón con la siguiente acción asignada:
Código:
on(rollOver) {
	mostrar('liderar');
}

on(rollOut) {
	ocultar('liderar');
}
Y en un frame tengo declaradas las funciones mostrar y ocultar:

Código:
function mostrar(id) {
	getURL("javascript:ocultar('bienvenidos');");
	getURL("javascript:mostrar('"+id+"');");
}

function ocultar(id) {
	getURL("javascript:ocultar('"+id+"');");
	getURL("javascript:mostrar('bienvenidos');");
}
Las funciones ocultar y mostrar de javascript simplemente cambian la propiedad style.display de un elemento a block o none.

Funciona en todos los navegadores menos en IE, alguna idea de por qué? La función de javascript funciona, pero la llamada desde flash no. A veces las muestra pero no las oculta, a veces no las muestra, es raro.

Gracias
Fede
__________________
Federico H. García
Desarrollo Web
www.federicog.com.ar
  #2 (permalink)  
Antiguo 09/01/2006, 22:11
 
Fecha de Ingreso: noviembre-2002
Ubicación: DF
Mensajes: 1.056
Antigüedad: 21 años, 4 meses
Puntos: 37
Con FSCOMMAND, se hace asi (tomado de la ayuda de flash)
Usage 2: To use fscommand() to send a message to a scripting language such as JavaScript in a web browser, you can pass any two parameters in the command and parameters parameters. These parameters can be strings or expressions, and they are used in a JavaScript function that handles, or catches, the fscommand() function.

In a web browser, fscommand() calls the JavaScript function moviename_DoFScommand, which resides in the webpage that contains the SWF file. For moviename, supply the name of the Flash object that you used for the NAMEattribute of the EMBED tag or the ID property of the OBJECT tag. If you assign the SWF file the name myMovie, the JavaScript function myMovie_DoFScommand is called.

In the web page that contains the SWF file, set the allowScriptAccess attribute to allow or deny the SWF file's ability to access the web page. (You set this attribute in the HTML code that embeds the SWF file--for example, in the PARAM tag for Internet Explorer or the EMBED tag for Netscape.) When allowScriptAccess is set to "never", outbound scripting always fails. When allowScriptAccess is set to "always", outbound scripting always succeeds. When it is set to "sameDomain", scripting is allowed only from SWF files that are in the same domain as the web page. If allowScriptAccess is not specified in a web page, it defaults to "sameDomain" for Flash Player 8, and to "always" for previous versions of Flash Player.

When using this function, consider the Flash Player security model. For Flash Player 8, the fscommand() function is not allowed if the calling SWF file is in the local-with-file-system or local-with-network sandbox and the containing HTML page is in an untrusted sandbox. For more information, see the following:

Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash
The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security
The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/fp8_security_apis
Usage 3: The fscommand() function can send messages to Macromedia Director. These messages are interpreted by Lingo (the Director scripting language) as strings, events, or executable Lingo code. If a message is a string or an event, you must write the Lingo code to receive the message from the fscommand() function and carry out an action in Director. For more information, see the Director Support Center at www.macromedia.com/support/director.
  #3 (permalink)  
Antiguo 10/01/2006, 00:31
 
Fecha de Ingreso: febrero-2005
Mensajes: 670
Antigüedad: 19 años, 2 meses
Puntos: 0
Gracias, pero no entendí exactamente que se supone que haga la función x_doFsCommand. Tengo que declararla yo con lo que quiero que haga? Sacarla de algún lado?

Gracias
Fede
__________________
Federico H. García
Desarrollo Web
www.federicog.com.ar
  #4 (permalink)  
Antiguo 10/01/2006, 14:25
 
Fecha de Ingreso: noviembre-2002
Ubicación: DF
Mensajes: 1.056
Antigüedad: 21 años, 4 meses
Puntos: 37
Entre otras cosas dice:
moviename_DoFScommand

crea una funcion que empiece igual q tu swf en el javascript, asi, si tu swf se llama "PELICULAPRUEBA.SWF" (y el parametro NAME de las tag flash dicen "PELICULAPRUEBA", entonces en tu codigo html puedes crear una funcion javascript:

function PELICULAPRUEBA_DoFScommand(){
alert('test')
}

Desde el flash debes ejecutar un fscommand, pero no tengo a la mano codigo de los parametros q se envian.
  #5 (permalink)  
Antiguo 10/01/2006, 18:19
 
Fecha de Ingreso: febrero-2005
Mensajes: 670
Antigüedad: 19 años, 2 meses
Puntos: 0
Sí, entendí eso, pero qué pasa si necesito llamar más de una función? tengo que poner todo lo que necesito adentro de esa? No es muy práctico :S
__________________
Federico H. García
Desarrollo Web
www.federicog.com.ar
  #6 (permalink)  
Antiguo 10/01/2006, 22:45
 
Fecha de Ingreso: febrero-2005
Mensajes: 98
Antigüedad: 19 años, 2 meses
Puntos: 0
Quizás esta dirección te pueda ayudar. (2do ejemplo)

http://www.macromedia.com/es/support...cript_comm.htm

Saludos
  #7 (permalink)  
Antiguo 11/01/2006, 13:32
 
Fecha de Ingreso: febrero-2005
Mensajes: 670
Antigüedad: 19 años, 2 meses
Puntos: 0
Gracias por el link, pero aparentemente ese método sólo funciona en IE.
¿Alguna otra idea?
__________________
Federico H. García
Desarrollo Web
www.federicog.com.ar
  #8 (permalink)  
Antiguo 11/01/2006, 13:44
 
Fecha de Ingreso: febrero-2005
Mensajes: 98
Antigüedad: 19 años, 2 meses
Puntos: 0
Dentro de ese link casi al final aparecen enlaces a otras páginas donde puedes ver la compatibilidad de los navegadores. Y si encuentras solución con respecto a este problema de la incompatibilidad de algunos browsers me avisas please

Gracias
  #9 (permalink)  
Antiguo 11/01/2006, 14:21
 
Fecha de Ingreso: febrero-2005
Mensajes: 670
Antigüedad: 19 años, 2 meses
Puntos: 0
No encontré nada estándar. Son todos métodos que hacen uso de tecnologías propietarias de IE y NS, ya sea Microsoft VBScript o Netscape LiveConnect :(

Si encuentro alguna solución aviso.

Suerte
Fede
__________________
Federico H. García
Desarrollo Web
www.federicog.com.ar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:02.