2009-04-08 8 views

Répondre

1

Il y a, même si cela m'a pris un peu de temps pour le trouver.

Cela devrait servir de très bon départ de chez vous: http://livedocs.adobe.com/flex/3/html/help.html?content=ProgrammingHTMLAndJavaScript_04.html

Voici le code clé:

var html:HTMLLoader = new HTMLLoader(); 
var foo:String = "Hello from container SWF." 
function helloFromJS(message:String):void { 
    trace("JavaScript says:", message); 
} 
var urlReq:URLRequest = new URLRequest("test.html"); 
html.addEventListener(Event.COMPLETE, loaded); 
html.load(urlReq); 

function loaded(e:Event):void{ 
    html.window.foo = foo; 
    html.window.helloFromJS = helloFromJS; 
} 

Le contenu HTML (dans un fichier test.html nommé) chargé dans l'objet HTMLLoader dans l'exemple précédent peut accéder à la propriété foo et à la méthode helloFromJS() définie dans le fichier SWF parent:

<html> 
    <script> 
     function alertFoo() { 
      alert(foo); 
     } 
    </script> 
    <body> 
     <button onClick="alertFoo()"> 
      What is foo? 
     </button> 
     <p><button onClick="helloFromJS('Hi.')"> 
      Call helloFromJS() function. 
     </button></p> 
    </body> 
</html> 
+0

Merci, fonctionne parfaitement! Je n'aurais jamais trouvé ça ... –