Saludos.

Tengo un problema, al usar el componente HTML para aplicaciones AIR, si el componente HTML usa una pagina que contiene por ejemplo un JavaScript que abre una popup, no funciona.

En Adobe encontre que hay que hacer una subclase de HTMLHost, en este caso llamada CustomHost para anular los metodos hereados de la clase HTMLHost para definir acciones cuando el código JavaScript de la página HTMLLoader define varias propiedades o llamadas a distintos métodos del objeto window.

Este el es código de CustomHost:

Código ActionScript :

package
{
    import flash.html.HTMLHost;
    import flash.html.HTMLLoader;
    import flash.display.NativeWindow;
    import flash.display.NativeWindowInitOptions;
    import flash.display.StageScaleMode;
    import flash.geom.Rectangle;
    import flash.text.TextField;

    public class CustomHost extends HTMLHost
    {
        import flash.html.*;
        public var statusField:TextField;
        public function CustomHost(defaultBehaviors:Boolean=true)
        {
            super(defaultBehaviors);
        }
        override public function windowClose():void
        {
            htmlLoader.stage.window.close();
        }
        override public function createWindow(windowCreateOptions:HTMLWindowCreateOptions):HTMLLoader
        {
            var initOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
            var window:NativeWindow = new NativeWindow(initOptions);
            window.visible = true;
            var htmlLoader2:HTMLLoader = new HTMLLoader();
            htmlLoader2.width = window.width;
            htmlLoader2.height = window.height;
            window.stage.scaleMode = StageScaleMode.NO_SCALE;
            window.stage.addChild(htmlLoader2);
            return htmlLoader2;
        }
        override public function updateLocation(locationURL:String):void
        {
            trace(locationURL);
        }        
        override public function set windowRect(value:Rectangle):void
        {
            htmlLoader.stage.nativeWindow.bounds = value;
        }
        override public function updateStatus(status:String):void
        {
            statusField.text = status;
        }        
        override public function updateTitle(title:String):void
        {
            htmlLoader.stage.nativeWindow.title = title + "- Example Application";
        }
        override public function windowBlur():void
        {
            htmlLoader.alpha = 0.5;
        }
        override public function windowFocus():void
        {
            htmlLoader.alpha = 1;
        }
    }
}


Luego la clase llamada SimpleHTMLBox añade un objeto HTMLLoader al escenario, así como un objeto TextField llamado statusBar.

Este es el código de SimpleHTMLBox:

Código ActionScript :

package
 {
     import flash.display.Sprite;
 
     public class SimpleHTMLBox extends Sprite
     {
         import mx.controls.HTML;
         import flash.html.HTMLLoader;
         import flash.text.TextField;
         import flash.net.URLRequest;
         import CustomHost;
         private var host:CustomHost;
         private var statusField:TextField;
         private var html:HTMLLoader;
         
         public function SimpleHTMLBox()
         {
             html = new HTMLLoader();
             var url:String = "Test.html";
             var urlReq:URLRequest = new URLRequest(url); 
             html.load(urlReq);
             
             host = new CustomHost();
             html.htmlHost = host;
             statusField = new TextField();
             host.statusField = statusField;
             
             configureUI();
         }
         private function configureUI():void
         {
             html.width = 400;
             html.height = 200;
             statusField.width = 400;
             statusField.height = 24;
             statusField.border = true;
             statusField.y = 200;
             
             addChild(html);
             addChild(statusField);                
         }
         
     }
 }


Este es el código del html llamado Test.html:

Código HTML :

<html>
     <head>
         <title>Test</title>
     </head>
     <body>
         <a href="#" onclick="window.open('Test.html')">window.open('Test.html')</a>
         <br/><a href="#" onclick="window.document.location = 'www.adobe.com'">window.document.location = 'www.adobe.com'</a>
         <br/><a href="#" onclick="window.moveBy(6, 12)">moveBy(6, 12)</a>
         <br/><a href="#" onclick="window.close()">window.close()</a>
         <br/><a href="#" onclick="window.blur()">window.blur()</a>
         <br/><a href="#" onclick="window.focus()">window.focus()</a>
         <br/><a href="#" onclick="window.status = new Date().toString()">window.status = new Date().toString()</a>
     </body>
 </html>


Ahora lo que me gustaria entender bien es la manera en que uso la clase, este es mi codigo en Flex:

Código Flex :

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication 
   xmlns:mx="http://www.adobe.com/2006/mxml"
   layout="absolute" 
   verticalScrollPolicy="off"
   horizontalScrollPolicy="off">
   <mx:HTML 
      location="Test.html" 
      left="10" 
      top="10" 
      bottom="10" 
      right="10"/>
</mx:WindowedApplication>


De antemano gracias por su ayuda.