0 Replies Latest reply on Jun 21, 2011 2:00 AM by Łukasz Wilk

    Scaling problem

    Łukasz Wilk

      Hello

       

      I'm creating an application that requires using and scalling of PDF and some custom components and I have run into a problem. Very basic layout of my app look like this:

      basic_layout.png

      The green area will be a container with a vertical scrollbar. As background i will use multiple PDF files closed in multiple SWF files arranged vertically. Content of this green area should resize acording to width which should be 100% all time and it must preserve aspect ratio. So far I can only resize PDF files using onResize event on which I do this:

       

      protected function handleResize(event:ResizeEvent):void
      {
         try
         {
            img1.height = group1.width * 830 / 550;
            img2.height = group2.width * 830 / 550;
                               
            group2.y = group1.height;
         }
         catch (e:Error) {}
      }
      

       

      830 is initial height, and 550 is initial width of PDF file.

       

       

      The code for this this area is:

       

      <s:Scroller id="scroller"
                  top="0" bottom="0" left="0" right="0">
                     
         <s:Group id="panel"
                  x="0" y="0"
                  width="100%" height="100%">
                     
            <s:Group id="group1"
                     x="0" y="0"
                     width="100%" height="100%">
                        
               <mx:SWFLoader id="img1"
                             source="assets/test36.swf"
                             width="100%"/>
                                  
               <s:TextInput id="testInput1"
                            x="345" y="130"
                            width="201" height="23"
                            text="LALALALA"/>
                                 
            </s:Group>
             
            <s:Group id="group2"
                     x="0" y="830"
                     width="100%" height="100%">
                        
               <mx:SWFLoader id="img2"
                             source="assets/test36.swf" 
                             width="100%"/>
                                  
               <s:TextInput id="testInput2"
                            x="345" y="130"
                            width="201" height="23"
                            text="LALALALA"/>
                                 
            </s:Group>
             
         </s:Group>
         
      </s:Scroller>
      

       

      Using this approach i can scale PDF files and keep their aspect ratio, but I don't think it's best and for sure not most eficient way of doing things. While this part somewhat scale ok, I can't seem to get TextInputs (later it will be my custom components) to scale and reposition themselves. I tryed using:

      - StageScaleMode.SHOW_ALL

      - resizeMode="scale"

      - my custom functions which made huge impact on performance

      - and some other ways I found on internet

      but unfortunatelly nothing worked the way i want to. I managed to see my desired effect (you can view it here: http://lukaszwilk.com/download/expected_result.swf) when I enclosed some TextInputs in the SWF file with PDF in Flash and now I try to find a way to do the same thing in Flex.

       

      I've run out of ideas how to do it and I hope someone from the comunity will be able to help me. If I didn't explain some parts clear enough please tell me and I will provide you with more details.