I am trying to create a header nav with roll over nav that remembers
your current selection.  For example, if you select Nav1 it should
show the Subnav1 menu.  If you were to check out the other nav
options, by rolling over only, but not actually select anything, I
want to return to the Subnav1 display when you return to the work
area.

I was trying to use mouseOut to reset the view, but it seems mouseOut
is being call inside the VBox.  I gave the VBox a background color of
red, I assume this is the area it should be using to say whether or
not the mouse is inside the VBox or not.  To see this, mouse over Nav3
and try to select the Nav3 submenu, you will see mouseOut being called
and resetting the view prematurely.

Is this a bug, am I taking something the wrong way that isnt intended,
or is there a work around?

Here's the code I tried to hack out for simplicity sake


// main.mxml application file

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:ns1="*">
      <ns1:nav id="navbar"/>
      <mx:Text text="{navbar.log}"/>
</mx:Application>


// nav.mxml component

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="onCreationComplete()"
      mouseOut="onMouseOut()" backgroundColor="red">

<mx:Script>
      <![CDATA[
            import mx.controls.Text;                  
            //import com.mycompany.myapp.model.ModelLocator;
            import mx.events.ItemClickEvent;
            import mx.core.Container;
           
            private var currentNav:Container;
                                     
            //[Bindable] public var model : ModelLocator =
ModelLocator.getInstance();
            [Bindable] public var model:Object = new Object();
           
            [Bindable] public var log:String;

            private function onCreationComplete():void {
                  model.workflowState=1;
                  updateCurrentNav();
            }
           
            private function onMouseOut():void {
                  log+="onMouseOut\n";
                  updateCurrentNav();
            }
           
        private function updateCurrentNav():void {
              subNavViewStack.selectedChild=getNavChild(model.workflowState);
        }           
                                                               
        private function handleTopNavClick(navClicked:int):void {
                  model.workflowState=navClicked;
                  updateCurrentNav();
            }           
           
            private function handleMouseOver(x:Number):void{
                  subNavViewStack.selectedChild=getNavChild(x);     
            }
           
        private function handleSubNavClick(event:ItemClickEvent):void {
              model.workflowState=event.item.data;
              updateCurrentNav();
        }           

        private function getNavChild(x:Number):Container {
              switch (x){
                    case 1:
                          return subNav1;
                          break;
                    case 3:
                          return subNav3;
                          break;                   
                    default:
                          return blank;
              }
        }           

      ]]>
</mx:Script>

<!-- header nav buttons -->
<mx:HBox horizontalGap="0">
      <mx:Button label="Nav 1" mouseOver="handleMouseOver(1)"
click="handleTopNavClick(1)"/>
      <mx:Button label="Nav 2" mouseOver="handleMouseOver(2)"
click="handleTopNavClick(2)"/>
      <mx:Button label="Nav 3" mouseOver="handleMouseOver(3)"
click="handleTopNavClick(3)"/>
</mx:HBox>     

<!-- sub nav roll over buttons -->
<mx:ViewStack id="subNavViewStack" height="26">
      <mx:Canvas id="blank"/>
      <mx:LinkBar id="subNav1" itemClick="handleSubNavClick(event)"
labelField="label">
            <mx:dataProvider>
                  <mx:Array>
                        <mx:Object label="Subnav1-1" data="">                         <mx:Object label="Subnav1-2" data=""                  
                        <mx:Object label="Subnav1-3" data="">                   </mx:Array>                 
            </mx:dataProvider>
      </mx:LinkBar>     
      <mx:LinkBar id="subNav3" itemClick="handleSubNavClick(event)"
labelField="label">
            <mx:dataProvider>
                  <mx:Array>
                        <mx:Object label="Subnav3-1" data="">                         <mx:Object label="Subnav3-2" data=""                  
                        <mx:Object label="Subnav3-3" data="">                   </mx:Array>                 
            </mx:dataProvider>
      </mx:LinkBar>           
</mx:ViewStack>

</mx:VBox>


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to