0 Replies Latest reply: Dec 19, 2012 12:35 PM by sgfone RSS

    htmlLoader heights do not get set if next page is a lessor height

    sgfone Community Member

      I have a small AIR app (Flash Builder 4.6) that loads HTML pages.  I am checking the height and find that the clientHeight or contentHeight or height get changed if the page is longer (a greater height) but does not change if the height is less.  I have included a test app I wrote to understand why my production app was not finding the correct height of the loaded page.  I have interogated/debugged the many, many heights in the htmlLoader DOM as well as AS3 heights - all to no avail.  Here is the example code I am using - thanks for any help/direction.

       

      <?xml version="1.0" encoding="utf-8"?>
      <!-- aircomponents/src/HTMLSimple.mxml -->
      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                             xmlns:s="library://ns.adobe.com/flex/spark" 
                             xmlns:mx="library://ns.adobe.com/flex/mx"
                               creationComplete="windowedapplication1_creationCompleteHandler(event)">
      
          <fx:Script>
              <![CDATA[
                  import mx.events.FlexEvent;
      
                  protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
                  {
                      content.addEventListener(Event.HTML_RENDER, onHTMLrender); 
                      content.addEventListener(Event.HTML_BOUNDS_CHANGE, onHTMLboundsChange);  
                      content.addEventListener(Event.LOCATION_CHANGE, onHTMLlocationChange);
                  }
      
                  protected function btnDebug_clickHandler(event:MouseEvent):void
                  {
                      trace("in btnDebug");
                  }
      
      
                  protected function onHTMLrender(event:Event):void
                  {
                      trace("evt.currentTarget.contentHeight is: " + event.currentTarget.contentHeight);
                  }
      
      // FUNCTION onHTMLboundsChange              
                  private function onHTMLboundsChange(event:Event):void
                  {
                      trace("in bounds change");
                  }
      
                  private function onHTMLlocationChange(event:Event):void
                  {
                      trace("in location change");
                  }
      
              ]]>
          </fx:Script>
      
      
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
      
          <s:layout>
              <s:VerticalLayout/>
          </s:layout>
      
          <s:Button id="btnDebug"  click="btnDebug_clickHandler(event)"/>
          <mx:ControlBar width="100%"> 
              <s:Button label="&lt; Back" 
                        click="content.historyBack();"/> 
              <s:Button label="Forward &gt;" 
                        click="content.historyForward();"/> 
              <s:TextInput id="address" 
                           text="{content.location}" width="100%"/> 
              <s:Button label="Go!" 
                        click="content.location = address.text"/> 
          </mx:ControlBar> 
          <s:Group width="100%" height="100%"> 
              <mx:HTML id="content" location="http://www.google.com/"/> 
          </s:Group>  
      </s:WindowedApplication>