2 Replies Latest reply on May 6, 2010 5:01 AM by welcomecan

    how i set icon in menu bar?

    welcomecan Level 1

      hi friends,

             now i am doing menubar program below sourcecode is here

       

       

      <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" creationComplete="onCC()" minWidth="955" minHeight="600">
      <fx:Script>
          <![CDATA[
             
                   import mx.controls.Alert;
              [Embed(source="images/images2.jpeg")]
              public var iconOne:Class;
          [Bindable]public var menuCollection:Array;
          private function onCC():void
          {
          menuCollection = [{label:"File" ,icon:"{iconOne}",children:[{label:"Item 1"},{label:"Item 2",children:["Sub Menu 1","Sub Menu 2"]}]}
              ,{label:"Edit",children:["Item 3","Item 4"]}];
         
            }
          ]]>

       

      </fx:Script>   
         
         
          <mx:ApplicationControlBar>
              <mx:MenuBar id="menu" dataProvider="{menuCollection}" iconField="@icon"/>
          </mx:ApplicationControlBar>
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
      </s:Application>

       

      any body give solution?

        • 1. Re: how i set icon in menu bar?
          Peter deHaan Level 4

          Your data provider isnt XML, drop the "@" in the iconField.

           

          <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"
                         creationComplete="onCC();">
              
              <fx:Script>
                  <![CDATA[
                      
                      import mx.controls.Alert;
                      
                      [Embed(source="assets/bullet_star.png")]
                      public const iconOne:Class;
                      
                      [Bindable]public var menuCollection:Array;
                      private function onCC():void {
                          menuCollection = [{label:"File" ,icon:iconOne, children:[{label:"Item 1"},{label:"Item 2",children:["Sub Menu 1","Sub Menu 2"]}]}
                              ,{label:"Edit", children:[{label:"Item 3", icon:iconOne},{label:"Item 4"}]}];
                      }
                  ]]>
              </fx:Script>    
              
              
              <s:controlBarContent>
                  <mx:MenuBar id="menu" dataProvider="{menuCollection}" iconField="icon"/>
              </s:controlBarContent>
              
          </s:Application>
          
          1 person found this helpful
          • 2. Re: how i set icon in menu bar?
            welcomecan Level 1

            i need without using class i want to set image in menu bar.

            give example

             

            regards,

            welcomecanv