1 Reply Latest reply on Apr 14, 2008 3:11 AM by dubbelugh2

    htmlLoader.contentWidth and contentHeight reporting 0

    tony0000000 Level 1
      Hi

      I'm trying to establish the height and width of the html content so that I can compare against the size of the app window and resize it to fit the content in a html / js app.

      When calling the code below I get a height and width of 0

      function test(){
      air.Introspector.Console.log(window.htmlLoader.contentWidth);
      air.Introspector.Console.log(window.htmlLoader.contentHeight);
      }

      Any ideas what I'm doing wrong?

        • 1. Re: htmlLoader.contentWidth and contentHeight reporting 0
          dubbelugh2
          Hi Tony,

          You get a width and height of 0 because the page isn't fully loaded yet. Try to add an eventListener (on EnterFrame) which checks if the HTMLLoader is loaded:

          _html.load(new URLRequest(" http://www.adobe.com")); // after the URLRequest start checking the load progress
          addEventListener(Event.ENTER_FRAME, _checkLoad);

          ------

          private function _checkLoad(e:Event):void
          {
          if (_html.loaded)
          {
          removeEventListener(Event.ENTER_FRAME, _checkLoad);
          trace(_html.contentWidth);
          trace(_html.contentHeight);
          };
          };