Skip to main content
Known Participant
December 12, 2013
Question

HTMLLoader not showing html page

  • December 12, 2013
  • 1 reply
  • 925 views

Hi! I've run into some problems using HTMLLoader on Mac OS X so I've created a simple Actionscript Project to test the basic functionality of this class. The code is as follows:

package

{

          import flash.display.Sprite;

          import flash.events.Event;

          import flash.html.HTMLLoader;

          import flash.net.URLRequest;

 

          public class Testhtml extends Sprite

          {

                    public function Testhtml()

                    {

                              var _webView:HTMLLoader = new HTMLLoader();

                              addChild(_webView);

                              var urlrqst:URLRequest = new URLRequest("test.html");

                              _webView.addEventListener(Event.COMPLETE,onLoad);

                              _webView.load(urlrqst);

                    }

 

                    protected function onLoad(event:Event):void

                    {

                              trace(event.target.location);

                    }

          }

}

test.html is just a simple

<!DOCTYPE HTML>

<html>

<body>

          hello

</body>

</html>

When I Debug the project nothing is shown. I can't see the "hello". Can anyone reproduce this issue? (I'm on Mavericks with AIR 3.9)

This topic has been closed for replies.

1 reply

Participating Frequently
February 12, 2014

Hi,

I have the same problem. Did you manage to find out a solution or a reason?

Best regards.

exprpubAuthor
Known Participant
February 17, 2014

It's been a while since I found a way to make it work. By having a look at my code now I can suggest that you try listening for the LocationChangeEvent.LOCATION_CHANGE instead of Event.COMPLETE. For some strange reason the latter is never fired in OS X.

Participating Frequently
February 17, 2014

Hi,

Thanks for your feedback.

Honestly it did not work, at least for me. Maybe i'm doing something wrong. Like i said before i'm opening a SWF in a native window, and this works fine on windows.
Do you have any out of the box idea?

Thanks in advance.

  var htmlLoader:HTMLLoader;

  htmlLoader = new HTMLLoader();

  stage.addChild(htmlLoader);

  htmlLoader.alpha = 0;

  htmlLoader.width = 1024;

  htmlLoader.height = 730;

  htmlLoader.navigateInSystemBrowser = true;

  var urlrqst:URLRequest = new URLRequest(urlSWF);

  htmlLoader.addEventListener(LocationChangeEvent.LOCATION_CHANGE,onLoad)

  htmlLoader.load(urlrqst);

  private function onLoad(event:flash.events.Event):void

  {

     trace("local " + event.target.location);

   }