2 Replies Latest reply on May 20, 2010 6:05 AM by jaywhy13

    "Out of view" viewstack does not invalidate children

    jaywhy13

      Hi all, I have a class I've made called a SlidingViewStack. It attaches itself to a canvas, turns the horizontal and vertical scroll policy off and sets clipContent to be true so that the view stack will be hidden when it is out of view. When the view stack is first initialized, the content is fine... however, when I change the selectedIndex of the view stack when it is not "in view" when I bring it back into view, all my labels are truncated.

      http://demo.monagis.com/flash/text_truncated.bmp

      As you can see from the image above "M.." is really supposed to say "Map Settings" and "B..." is "Base Map"


      I have tried calling validateNow(), invalidateDisplayList(), invalidateProperties(), invalidateSize() on the VBox (container for the elements)... none work. I've tried invalidating the label on roll over and that makes the label repaint as quickly as I hover over it. Any advice on approach here? I'm left to think that the kids of the VBox are not being invalidated properly or something.

        • 1. Re: "Out of view" viewstack does not invalidate children
          BhaskerChari Level 4

          Have you set the resizeToContent="true" on ViewStack....If not try to set that propert and check once...

           

          If your problem is not solved try posting sample code reproducing the problem.

           

          If this post answers your question or helps, please kindly mark it as such.

           

          Thanks,

          Bhasker Chari

          • 2. Re: "Out of view" viewstack does not invalidate children
            jaywhy13 Level 1

            That hasn't changed anything... I'll try as best as possible to explain it. It's a big class.

            It's called a ViewStackSlider... it has a "tray" that holds icons and an array of containers. So...



            public function addSlidingContent(icon:Image,container:Container):void {

            // Add the icon

            icons.addItem(icon);

            configureTrayIcon(icon,icons.length-1);

            tray.addChild(icon);

             

            // Add container

            containers.addItem(container);

            viewStack.addChild(container);

            icon.addEventListener(MouseEvent.CLICK,iconClicked);


            // Show the tray... this might not show anything... show icon tray does checks before showing

            showIconTray(); // pop open the icon tray

            }


            Above, I add an icon and a container. I add some listeners to the icon so that when the icon is clicked, the view stack slides in. Basically, when the user clicks an icon.. activateContent(number) is called.. where number is an index into the array collection.
            /**
            * Activates an index, and slides up the view stack
            */
            public function activateContent(index:Number):void {
            if(index >= containers.length) {
            Application.application.cwmTrace(name + ": cannot activate index: " + index);
            return;
            }
            Application.application.cwmTrace(name + ": activating: " + index);
            var container:Container = containers.getItemAt(index) as Container;
            viewStack.selectedIndex = index;
            container.invalidateDisplayList();
            container.invalidateProperties();
            container.invalidateSize();
            slideStackIn();
            activeIndex = index;
            }
            So I get the container, change the view stack selected index to that index, try and invalidate the container and then I call slideStackIn()
            public function slideStackIn():void {
            Application.application.cwmTrace(name + ": Sliding stack in");
            if(viewStackCanvas.parent == null) return;
            if(!effectParamsValid) updateEffectParameters();
            if(viewStackCanvasState == COMP_HIDDEN){
            inEffect.play();
            } else {
            focus();
            }
            }
            I actually have the viewstack in a canvas, viewStackCanvas and I move the canvas around... so the canvas contains the view stack and I animate the canvas. In effect slides the canvas from being "out of view" into view where the user can see it. The view stack canvas hides outside the boundaries of it's parent until the slideStackIn() method is called.
            Hope this is clear. Thanks for the help thus far.

             

            Reformatted the text so the code was distinguishable from text.