4 Replies Latest reply on Apr 20, 2011 1:00 PM by mac1160

    Re-enable HScrollbar

    mac1160

      Created a HScrollbar in FLEX, comes up ok when the app is displayed.  I have code that makes it not visible when the panel it resides in is resized.  That works.  However, on a mouse-up event I check the width of the panel and if a certain value, I want the HScrollbar to be visible again and functional.  It becomes visible but seems greyed out and non functioning.  I've tried everything such as:

       

                          if (ComponentsPanel.width == 227 ) {
                              Hbar.visible = true;
                              Hbar.enabled = true;
                              Hbar.currentState = "";
                              Hbar.initialize();
                          }

      what an I not doing? or doing wrong?

       

      Thanks.

       

      ~Mike

        • 1. Re: Re-enable HScrollbar
          Lee Burrows Level 4

          hi

           

          the line Hbar.currentState = ""; looks a bit suspect - i didnt think you could have a state with a zero length name?

           

          can you post your actual code....

          • 2. Re: Re-enable HScrollbar
            mac1160 Level 1

            Lee,

             

            Thanks, setting currentstate to null or "" is supposed to reset the component.  OK, here is full code that moves panel via mouse, all works except restore of Hbar;  mousedownevent listener is registered in panel init function 'oncomplete' not shown

             

                        public function mouseOverHandler( event:MouseEvent) :void {
                            if (event.buttonDown == false && Left == true) {
                                Left = false;
                                //kill mouse movement
                                ComponentsPanel.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
                            }
                        }

             

             

             

                        private function mouseUpHandler( event:MouseEvent ):void {
                            event.stopImmediatePropagation();       
                            if (ComponentsPanel.width <= 50)
                            {   //panel width below min for TOC visible, reset to allow table of content visible
                                ComponentsPanel.width = 50;
                                myGroup.width = 50;
                                tocTree.width = 50;
                            }
                            else
                            {   //set components to new width, set via mouse movement
                                ComponentsPanel.width = xOff;
                                myGroup.width = xOff;
                                tocTree.width = xOff;
                                //reset HScrollbar if original panel width
                               if (ComponentsPanel.width == 227 ) {
                                    Hbar.visible = true;
                                    Hbar.enabled = true;
                                    Hbar.currentState = "";
                                    Hbar.initialize();
                                }

                            }
                            Left = false;  //reset panel move in progess
                            //remove events no longer needed until next desired panel move
                            ComponentsPanel.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
                            ComponentsPanel.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
                            ComponentsPanel.removeEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
                        }

             

                        protected function mouseMoveHandler(event:MouseEvent):void {
                            event.stopImmediatePropagation();       
                               
                            if (event.buttonDown == true) {
                                if (SkinObject.ySkin >= 0 && SkinObject.ySkin <= 22) {
                               
                                    if ((directionX - SkinObject.ySkin >= 0 && event.target.x != 1) || (directionX >= 10 && event.target.x != 1) ) {
                                        xOff = xOff + 2;
                                        if (SkinObject.ySkin >= 0 && SkinObject.ySkin <= 22) {
                                            ComponentsPanel.width = xOff;
                                            myGroup.width = xOff;
                                            tocTree.width = xOff;
                                            Left = true;
                                            Hbar.visible = false;
                                        }
                                    }
                                    else {
                                        xOff = xOff - 2;
                                        if (SkinObject.ySkin >= 0 && SkinObject.ySkin <= 22) {
                                            ComponentsPanel.width = xOff;
                                            myGroup.width = xOff;
                                            tocTree.width = xOff;
                                            Left = true;
                                           Hbar.visible = false;
                                        }
                                    }
                                } //skin
                                else {
                                    ComponentsPanel.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
                                }

             

                            }  //mouse up

             

                            if (SkinObject.ySkin >= 0 && SkinObject.ySkin <= 22) {
                                //trace("no kill mouse move");
                            }
                            else {
                                ComponentsPanel.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
                            }    
                        }

             

                        public function mouseDownHandler(event:MouseEvent):void {
                            initX = event.localX;
                                       
                            if (SkinObject.ySkin >= 0 && SkinObject.ySkin <= 22) {
                                directionX = SkinObject.ySkin;
                                ComponentsPanel.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
                                ComponentsPanel.addEventListener( MouseEvent.MOUSE_MOVE, mouseMoveHandler );
                                ComponentsPanel.addEventListener( MouseEvent.MOUSE_UP, mouseUpHandler );
                            }
                        }

             

                    ]]>
                </fx:Script>

             

                <s:layout>
                    <s:HorizontalLayout  />
                </s:layout>
               
                <s:Panel id="ComponentsPanel"
                title="Components"
                skinClass="skins.VerticalSkin"
                width="227" height="445" 
                resize="true"
                x="0"  y="0" >
                   
                    <s:VGroup>
                       
                        <s:Group id="myGroup" width="200" height="421" clipAndEnableScrolling="true">
                           
                            <mx:Tree id="tocTree"
                                     labelField="@label"
                                     itemOpen="updateSelection()"
                                     itemClick="selectItem()"
                                     width="360" height="475"
                                     x="-1" y="0"                
                                     includeIn="Default,Default_Compact,Default_Minimized,Full,Full_Compact,Full_Minimized"
                                     color.Full_Minimized="#000000"
                                     contentBackgroundColor="#CACACA">
                            </mx:Tree>
                           
                        </s:Group>
                       
                        <s:HScrollBar   id="Hbar" viewport="{myGroup}" height="43" width="200"  />
                       
                    </s:VGroup>
                   
                </s:Panel>

            • 3. Re: Re-enable HScrollbar
              Lee Burrows Level 4

              hi

               

              not sure what you are trying to do - your scrollbar acts on the vgroup but the panel isnt inside the vgroup so why affect the scrollbar?

               

              presumably the scrollbar is greyed out before you hide it? so it will still be greyed out after the panel move

              • 4. Re: Re-enable HScrollbar
                mac1160 Level 1

                HScrollbar is enabled before the panel is moved horizontally but once moved it is no longer enabled.