2 Replies Latest reply on Jan 4, 2011 9:51 PM by Flex harUI

    A drop down list rollover open?

    MiMeeLunLa

      I want to make a drop down list menu which open when mouse-over not click but I can't do it

      Is anybody can insert that code for me? Thank you so much

       

      <?xml version="1.0" encoding="utf-8"?>
      <!--created:Aug 26, 2010 file:DropDownListDemo2.mxml  author:Michael -->
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"              
                 xmlns:s="library://ns.adobe.com/flex/spark"              
                 xmlns:mx="library://ns.adobe.com/flex/mx" viewSourceURL="srcview/index.html" width="1016" height="743" xmlns:ns1="*">
                       
            <fx:Style>        
               @namespace s "library://ns.adobe.com/flex/spark";        
               s|DropDownList #labelDisplay        
               {   font-weight:bold;           
                  color:#45497c;           
                  font-style:italic;          
               } 
              
            </fx:Style> 
         <fx:Script>       
            <![CDATA[ 
        
               import mx.collections.ArrayList;
               import mx.events.FlexEvent;            
               [Bindable]           
               private var dropListDb:ArrayList;
              
               protected function dl_creationCompleteHandler(event:FlexEvent):void           
               {                
                  dropListDb=new ArrayList();
                  dropListDb.addItem({label: "Bachelor"});
                  dropListDb.addItem({label: "Master"});                
                  dropListDb.addItem({label: "Doctor"}); 
                  this.dl.prompt="Degree";
                       
                  //this.dl.openDropDown();  setค่าเริ่มต้นโชว์เลย
                  //creationComplete="dl_creationCompleteHandler(event)"
               }      
           
              ]]>

         </fx:Script>    

        
         <mx:Image source="C:\Users\Beaut\Desktop\newbgresize.jpg" x="0" y="0" height="589" width="1024"/>
         <s:DropDownList id="dl" 
                       
                     dataProvider="{dropListDb}"                 
                     alternatingItemColors="[0x88c3f0,0xbbdef9]"                 
                     width="131" skinClass="MyDropDownListSkin"                   
                     itemRenderer="MyDropDownListItemRenerer"                   
                     chromeColor="0x62b6f7"  x="50" y="146" height="22"
                     creationComplete="dl_creationCompleteHandler(event)"
                   
                        
      </s:Application>

       

      and the ItemRenerer

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"               
                  xmlns:s="library://ns.adobe.com/flex/spark"               
                  xmlns:mx="library://ns.adobe.com/flex/mx"               
                  autoDrawBackground="true">    
         <s:states>       
            <s:State name="normal"/>        
            <s:State name="hovered"/>        
            <s:State name="selected"/>   
         </s:states>    
         <s:Label text="{data.label}"
                backgroundColor.selected="#2a1592" color.selected="white"         
                backgroundColor.hovered="white" color.hovered="blue" fontWeight.hovered="bold"            
                width="100%" height="25" paddingLeft="5" paddingTop="5"/> 

      </s:ItemRenderer>

       

      form the code I got my drop down list which open when I click.I don't know how to write rollover-open function

      Thank you so much