4 Replies Latest reply on May 28, 2010 3:20 AM by Ling's

    CheckBox  AddEventListener in subclass itemrenderer

    Ling's

      I have using a menubar  and checkbox., menubar iconfiled to  displayed images in subclass itemrenderer.. when i select check, image is display otherwise iconfiled image not display. how to call eventLIstener in subclass itemrenderer.,

       

      Any one help..

       

       

      With Regards.,

      Lings

        • 1. Re: CheckBox  AddEventListener in subclass itemrenderer
          BhaskerChari Level 4

          Hi,

           

          Please try to post some of the sample code depicting your problem.

           

          Thanks,

          Bhasker Chari

          • 2. Re: CheckBox  AddEventListener in subclass itemrenderer
            Ling's Level 1

            mxml coding..

             

            <fx:script>

            function init(event):void
                        {
                         
                            chk.addEventListener('change', regular);
                        }
                       
                        public function regular():void
                        {
                            trace("regular Listener");
                        }

            <fx:script>

             

            <s:HGroup paddingLeft="10" paddingRight="20" paddingTop="20" width="100%" height="100%">
                    <s:CheckBox id="chk" change="dispatchEvent( new Event('change', true ) );"  label="Menubar Img ON">       
                    </s:CheckBox>
                    <MyMenuBar id="testmenu"   labelField="menuLabel"    menuBarItemRenderer="com.vo.MyMenuBArItem"   dataProvider="{Datamenu}"         width="100%" itemClick="ClickMenuItem(event);" click="Select_MenuBar(event);" />
             
                </s:HGroup>

             

            itemrenderer

            MyMenuBArItem.as

            package com.vo

             

            {

             

                import flash.events.MouseEvent;

             

             

             

                import mx.collections.ArrayCollection;

             

                import mx.controls.CheckBox;

             

                import mx.controls.Image;

             

                import mx.controls.Menu;

             

              import mx.controls.menuClasses.MenuBarItem;

             

                import mx.controls.menuClasses.MenuItemRenderer;

             

                import mx.rpc.events.ResultEvent;

             

             

                public class MyMenuBArItem extends  MenuBarItem

             

                {

             

                    private var image:Image;

                    private var testcheck:mx.controls.CheckBox;

                    private var selected:Boolean;

             

                    public function MyMenuBArItem()

             

                    {

             

                        super();

             

                    }

             

                    override protected function commitProperties():void

             

                    {

             

                        super.commitProperties();

                    this.addEventListener('change', onchange,false,0,true);

             

                            var icon:String = data.menuIcon;

             

                            image = new Image();

             

                            image.source = icon;

             

                            addChild(image);

             

                    }

             

                    public function onchange(testcheck:Object):void

             

                    {

                        if(testcheck.selected== true)

             

                        {

             

                            image.visible= false;   

                    }

             

                        else

             

                        {

             

                            image.visible=true;

             

                        }

             

                    }

             

            any one help . how to addeventListener in submenu itemrenderer.. checkbox event.

             

            Lings

            • 3. Re: CheckBox  AddEventListener in subclass itemrenderer
              BhaskerChari Level 4

              Hi,

               

              If I get you right ...you want to dispatch an event in your itemrenderer when "testcheck" checkbox status is changed and you want to capture this and listen for this event in main application.

               

               

               

              Thanks,

              Bhasker Chari

              • 4. Re: CheckBox  AddEventListener in subclass itemrenderer
                Ling's Level 1

                Hi

                how to change this code..

                any sample coding ..?

                 

                lings