1 Reply Latest reply on Jun 10, 2009 6:03 AM by Cesare Rocchi

    Windows - restoring window causes VBox to scroll to top

    SilentChris Level 1

      It's basically as the title says - when I have a VBox with scrolling content, whenever I minimize then restore the AIR app on windows, the VBox scrolls to the top, regardless of its scroll position before minimizing.

       

      This doesn't seem to happen on Mac (I haven't tried on Linux).  Some code to reproduce is below.  If you run it as an AIR app and minimize and restore the window, you'll see the problem.

       

      I think I can fix it by manually scrolling when the windowActivate event fires (focusIn doesn't work - the event fired when I was in debug mode, but not when I made a release build).  Has anyone else had this problem, or know of a better fix?  I think it just a bug in AIR on windows - here's hoping someone at Adobe see this and can fix it =)

       

      Code:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="addChildren()" width="600" height="500">
           <mx:Script>
                <![CDATA[
                     import mx.controls.Label;
                     internal function addChildren():void {
                          for (var i:int = 0; i < 100; i++) {
                               var l:Label = new Label();
                               l.text = "line";
                               l.width = 50;
                               this.content_vbox.addChild(l);
                          }
                     }
                ]]>
           </mx:Script>
           <mx:Canvas borderColor="#FFFFFF" backgroundAlpha="1.0" backgroundColor="#FFFFFF" left="10" top="10" right="150" bottom="10">
                <mx:VBox height="100%" left="0" top="0" right="0" id="content_vbox">
                </mx:VBox>
           </mx:Canvas>
           
      </mx:WindowedApplication>