12 Replies Latest reply on Mar 13, 2009 1:06 PM by (Philippe_Dubois)

    this.hostContainer is undefined when pdf is in air

      Hi,<br />I'm attempting to use the hostContainer object to create a simple interface to allow my Adobe Air application to move between pages of an embedded pdf doc. However the output I get indicates that the  hostContainer object is undefined. The script works correctly when the pdf is embedded in a stand-alone html file, but not in Air.<br /><br />My code in the document javascripts of the pdf is as follows:<br /><br />this.disclosed = true;<br />if(this.external && this.hostContainer){ <br />  try{<br />    this.hostContainer.messageHandler={<br />     myDoc:this,<br />     onDisclose:function(){return true;},<br />     onMessage:function(stringArray){<br />       var cmd=stringArray[0];<br />        try{<br />               if(cmd=="nextPage" && this.myDoc.pageNum<this.myDoc.numPages){<br />                   this.myDoc.pageNum++;<br />               }else if(cmd=="previousPage" && this.myDoc.pageNum>0){<br />                   this.myDoc.pageNum--;<br />               }<br />             }catch(e){<br />               this.hostContainer.postMessage(<br />                   ["error thrown in onMessage:",e.message]);<br />             }<br />         },<br />         onError:function(e){<br />             this.hostContainer.postMessage(["onError: ",e.message]);<br />         }<br />    }<br />  }catch(e){<br />    this.hostContainer.postMessage(["Error thrown in setup:",e.message]);<br />  }<br />}else{<br />    app.alert("unable to set up hostContainer: this.hostContainer="<br />        +this.hostContainer+" this.external="+this.external);<br />}<br /><br />The output is that the pdf displays correctly then the alert box pops up with [...]this.hostContainer=undefined this.external=true.<br /><br />If anyone can shed some light here I would be most grateful.<br /><br />Thanks,<br />Simon Kelly