I'm trying to setup a system that will allow the user to view PDF forms within my Flex app. I have created a WindowedApplication containing a HBox with contains a HTML control. My problem right now is that the PDF will display, but the window does not open at a good size for viewing. When I resize the window to better view the PDF, it appears that the HBOX or HTML control is not resizing properly. Here is the code I have so far: <?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" resize="resizeWindow()"> <mx:Script> <![CDATA[ import flash.events.Event; import mx.events.DropdownEvent; public var filepath:String; public var index:int; public var pdf:HTMLLoader; private function ResizeViewer():void{ pdf.height = PDFViewer.height pdf.width = PDFViewer.width } private function resizeWindow():void{ if this.is hboxHtml.height = this.height; hboxHtml.width = this.width; } // Display a selected item's label field and index for change events. private function changeEvt(event:Event):void { filepath = cmbForms.text; index = cmbForms.selectedIndex switch (index) { case 0 : filepath = "C://PDF Docs//822 Individualized Treatment Plan 6-29-2009 (Reader).pdf"; case 1 : filepath = "C://PDF Docs//822 Psychosocial 6-3-2009 (Reader).pdf"; case 2 : filepath = "C://PDF Docs//822 Utilization Review Form (Reader).pdf"; } PDFViewer.removeChildAt(0); var request:URLRequest = new URLRequest(filepath) //("http://www.example.com/test.pdf"); pdf = new HTMLLoader(); pdf.height = PDFViewer.height; pdf.width = PDFViewer.width; pdf.load(request); PDFViewer.addChildAt(pdf, 0); lblTest.text = filepath; } ]]> </mx:Script>
<mx:HBox x="0" y="95" width="100%" height="266" verticalAlign="bottom" id="hboxHtml" resize="resizeHBox()"> <mx:HTML id="PDFViewer" width="100%" height="90%" resize="ResizeViewer()" /> </mx:HBox> <mx:Form x="0" y="0" width="100%" height="87" id="controlForm"> <mx:Label text="Select Form"/> <mx:ComboBox width="293" id="cmbForms" visible="true" change="changeEvt(event)" > <mx:dataProvider> <mx:ArrayCollection> <mx:Object label="822 Individualized Treatment Plan" data="C:\PDF Docs\Individualized.pdf"/> <mx:Object label="822 Psychosocial" data="C:\PDF Docs\Psychosocial.pdf"/> <mx:Object label="Utilization Review Form" data="C:\PDF Docs\UtilizationReview.pdf"/> </mx:ArrayCollection> </mx:dataProvider> </mx:ComboBox> <mx:Label id="lblTest" text="Label"/> </mx:Form> </mx:WindowedApplication> As you can see this is a very basic form. This is the first project in FLEX so I'm still learning. My ResizeViewer and ResizeWindow functions don't seem to work as expected. Thanks for any advice that you can give.