2 Replies Latest reply on Dec 27, 2012 7:44 AM by sgfone

    How to communicate between an AIR app and HTML loaded via htmlLoader

    sgfone

      Hi.  I have written an AIR app using Flash Builder 4.6 that is called by a SWF.  The SWF passes the AIR app some parameters which include which web page to load.  The AIR app then sets up an event listener for "onLoadComplete" and when the web page is loaded I try to determine the height of the loaded page.  I do this via the "browserInsideFlex.htmlLoader.window.document.body.clientHeight" (where "browserInsideFlex" is the ID of the <mx:HTML id="browserInsideFlex"  verticalScrollPolicy="off" horizontalScrollPolicy="off" />.

       

      The height seems correct until a page is loaded whose height is less that the preveiously loaded page.  When a page is which is loaded whose height is less that the preveiously loaded page, the height remains at the previous height.  For example, if I load a page whose height is 2000, then load a page whose height is 2500, the height is 2500.  But if I then load a page whose height is 1500, the height is still 2500.

       

      So - I thought I might use ExternalInterface to get to the height instead (thinking that maybe Flex determined height is not the same at the DOM height???).  When I try to use ExternalInterface in an AIR app I get the message saying it is not available. 

       

      Summary

      =======

      1.  How to I use ExternalInterface in an AIR app (or what is an the alternative way)?

       

      2.  How do I get the correct height of an htmlLoader page?

       

      3.  I also have a problem getting the correct vertical scroll position (it is always 0 even when the scroll bar in at the bottom of the page.  I think this may be related to my determining DOM related attributes.

       

      Thanks for any help/direction.  I have scoured Adobe AS3 reference and the internet forums and examples. 

        • 1. Re: How to communicate between an AIR app and HTML loaded via htmlLoader
          l33tian Level 1

           

           

          I have written an AIR app using Flash Builder 4.6 that is called by a SWF.  The SWF passes the AIR app some parameters which include which web page to load.

          I dont really understrand that line. Do you mean the air app calls a swf. ExternalInterface only communicates with a swf ( inside an html page ) and your AIR app.

          • 2. Re: How to communicate between an AIR app and HTML loaded via htmlLoader
            sgfone Level 1

            Sorry for the misunderstanding.

             

            The AIR app acts as a utility that is called by a Flash developed app (a SWF).  That SWF app calls the AIR app, passing it a parm on which page (e.g. http://pageToLoad.com) to load.  So, no, the AIR app does not call a SWF but rather the SWF calls the AIR app.  The AIR app then loads the requested page.  After the load I am trying (in the AIR app) to get the height of the loaded page (among other info).  I use the "browserInsideFlex.htmlLoader.window.document.body.clientHeight" but the height does not seem to be correct if the height of the loaded page is less than the previously loaded page (I know - it sounds strange) - the height seems to remain at the largest height number of all the previously loaded pages.  Not sure if a bug or not - I have been trying to solve this for about a month - feel kind of naive.

             

            Let me know if you need any more info.