Comunidad de diseño web y desarrollo en internet online

ExternalInterface no funciona en Firefox

Citar            
MensajeEscrito el 09 Ene 2010 02:25 pm
Tengo dos enlaces en HTML y el objetivo es que un swf informe cuál de ellos fue clicado. Lo curioso es que funciona en el Internet Explorer pero no lo hace en el Firefox.

Mi AS3 es este:

Código ActionScript :

import flash.external.ExternalInterface;

var texto:String;

ExternalInterface.addCallback("clickBoton1", LinkUno);
ExternalInterface.addCallback("clickBoton2", LinkDos);

function LinkUno():void
{
   texto = "Fue clicado el primer link";
   mostrar();
}

function LinkDos():void
{
   texto = "Fue clicado el segundo link";
   mostrar();
}

function mostrar():void
{
   txtCampo.text = texto;
}


y el HTML este:

Código 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>Enlaces</title>
<script type="text/javascript" src="swfobject.js"></script>  
<script type='text/javascript'>
function ClicadoUno()
{
   document.getElementById("myId").clickBoton1();
}
function ClicadoDos()
{
   document.getElementById("myId").clickBoton2();
}
</script>
</head>
<body>
<p><a href="#" onclick="ClicadoUno() ;return false">Link 1</a>
</p>
<p><a href="#" onclick="ClicadoDos() ;return false">Link 2</a></p>
<div>   
         <object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="300" height="200">
            <param name="movie" value="links.swf" />
              <!--[if !IE]>-->
            <object type="application/x-shockwave-flash" data="links.swf" width="300" height="200">
            <!--<![endif]-->
            <!--[if !IE]>-->
            </object>
            <!--<![endif]-->
         </object>
</div>
</body>
</html>


Alguna idea de cómo resolver este problema?. Desde ya muchas gracias. Claudio

Por Ishkandar

Claber

303 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 09 Ene 2010 02:47 pm
Para que funcione bien ExternalInterface , el id del object como el param name del tag embed , debe ser el mismo.


Jonathan

Por maneuver

243 de clabLevel



Genero:Masculino  

Mexico City

firefox
Citar            
MensajeEscrito el 09 Ene 2010 03:06 pm
Jonathan, el id del object es "myId" y el parámetro name es "movie".

Cuando coloqué los dos valores iguales( "myId") dejó de funcionar hasta en el Explorer. Qué estoy haciendo mal?

Por Ishkandar

Claber

303 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 09 Ene 2010 03:37 pm
haver prueba con esto..

Código ActionScript :

if(ExternalInterface.available) {
   ExternalInterface.addCallback("checkClick",displayClick);
}

function displayClick(paramRef:String):void
{
   //tDisplay es el campo de texto
   tDisplay.text = paramRef;
}


Código HTML :

<html>
<head>
   <title>Demo External Interface</title>
    <script language="JavaScript" type="text/javascript">
    function getMyApp(appName) {
        if (navigator.appName.indexOf ("Microsoft") !=-1) {
            return window[appName];
        } else {
            return document[appName];
        }
    }
    function clickHandler(pRef) {
      alert(getMyApp("mySwf"));
        getMyApp("mySwf").checkClick(pRef);
    }
</script>
</head>
<body>
   <p><a href="#" onClick="clickHandler('link 1 clickado')";>Link 1</a></p> 
<p><a href="#" onClick="clickHandler('link 1 clickado')";>Link 2</a></p> 
    <div>
        <object id='mySwf' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab' height='150' width='250'>
                <param name='src' value='demoExternalInterface.swf'/>
                <param name='flashVars' value=''/>
                <embed name='mySwf' src='demoExternalInterface.swf' pluginspage='http://www.adobe.com/go/getflashplayer' height='100%'       width='100%' flashVars=''/>
            </object>
    </div>
</body>
</html>


solo sustituye value='demoExternalInterface.swf' ,src='demoExternalInterface.swf' por los nombres de tu archivo swf. este codigo lo probe en IE y Mozilla y funciona bien, espero te funcione.

Jonathan

Por maneuver

243 de clabLevel



Genero:Masculino  

Mexico City

firefox
Citar            
MensajeEscrito el 09 Ene 2010 05:47 pm
Amigo Jonathan:

Funcionó bien en ambos navegadores y quedó mas organizado facilitando el objetivo final que es el siguiente. Tengo un player swf que toca MP3 cargados através de XML que es llamado via HTML . Se me solicitó ahora la inserción de un segundo CD; inicialmente pensé colocar un condicional en el as3 para que dependiendo de la string que viniese del html mandase cargar el XML correspondiente al CD1 o al CD2. Pero de la forma que hiciste puedo enviar el camino (path) directamente con pRef evitando aquel condicional.

Muchas gracias, un abrazo. Claudio

Por Ishkandar

Claber

303 de clabLevel



Genero:Masculino  

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.