Unable to call the click event handler for a button added in the Accordian header

36 views
Skip to first unread message

madhavi chinni

unread,
Oct 26, 2012, 10:59:59 PM10/26/12
to flex_...@googlegroups.com

Hi,
I have created a custom Accordian Header and I have added a button,image,linkButton in the Accordian header.
I want to perform a functionality in the click event handler of the button which is added in the Accordian header,but the code in the click event handler of the button added in the Accordian header is not called.
I tried alerting a statement in the click event handler of the button added in the Accordian header,but the alert statement is not printed.
Any help is greatly appreciated :) .  Its Urgent!!!
Please find the code snipplet pasted below.

public class CustomAccordianHeader extends AccordionHeader
    {
   
       
        [Bindable]
        [Embed(source="assets/plus.jpg")]
        private var AccordionIcon:Class;
       
        //private var extraButton : Button = new Button();
        private var extraButton : CustomButton = new CustomButton();
        private var image:Image = new Image();
        private var extraLink:LinkButton = new LinkButton();
        private    var box:HBox = new HBox();
       
       
       
        public function CustomAccordianHeader()
        {
            super();
            this.setStyle("skin",comp.CustomSkin);
            this.useHandCursor =  true;
            this.mouseChildren =  true;
            this.buttonMode =  true;
            this.addEventListener(MouseEvent.CLICK,showHeader);
           
            image.source = AccordionIcon;
           
            //extraButton.label= "hello";
            //extraButton.addEventListener(MouseEvent.CLICK,displayHi);
       
           
            //extraButton.buttonMode = true;
            //extraButton.useHandCursor = true;
            //extraButton.mouseChildren =  true;
           
            extraLink.label = "Madhu";
            extraLink.addEventListener(MouseEvent.CLICK,displayHello);
            extraLink.buttonMode = true;
            extraLink.useHandCursor = true;
            extraLink.mouseChildren =  true;
        }
       
        override protected function createChildren():void{
            super.createChildren();
           
            box.addElement(extraLink);
            box.addElement(image);
            box.addElement(extraButton);
           
            addChild(box);
        }
       
        public function showHeader(event:MouseEvent):void{
            Alert.show("header");
        }
       
       
        override protected function updateDisplayList( unscaledWidth : Number, unscaledHeight : Number ) : void {
            super.updateDisplayList(unscaledWidth, unscaledHeight);
           
            /* extraButton.setActualSize(50, unscaledHeight - 6);
            extraButton.move(unscaledWidth - extraButton.width - 3, (unscaledHeight - extraButton.height)/2);  */
            box.setActualSize(200, unscaledHeight - 6);
            box.move(unscaledWidth - box.width - 3, (unscaledHeight - box.height)/2);
        }
       
        public function displayHi(event:MouseEvent):void{
            Alert.show("hi");
        }
       
        public function displayHello(event:MouseEvent):void{
            Alert.show("hello");
        }
    }

Thanks & Regards,
Madhavi

mohammed azeem

unread,
Oct 29, 2012, 1:34:25 AM10/29/12
to flex_...@googlegroups.com

check this link ,  below link suggests you to use custom event , thats the code you need to use in your 
accordian header , try it out


http://stackoverflow.com/questions/4875315/add-button-to-the-flex-accordion-header-which-can-clickable




--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To view this discussion on the web visit https://groups.google.com/d/msg/flex_india/-/W5c8DsWWXigJ.
To post to this group, send email to flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.

madhavi chinni

unread,
Oct 29, 2012, 8:33:51 AM10/29/12
to flex_...@googlegroups.com
I tried this.It is not working :(
--
To the Question of ur life,
u r the only Answer,
To the Problems of ur life,
u r the only Solution
...

rames...@gmail.com

unread,
Oct 30, 2012, 4:09:15 AM10/30/12
to flex_...@googlegroups.com
Alert works just fine for me...

On Sat, Oct 27, 2012 at 8:29 AM, madhavi chinni <madhugee...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To view this discussion on the web visit https://groups.google.com/d/msg/flex_india/-/W5c8DsWWXigJ.
To post to this group, send email to flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.



--
Fear is an illusion, So, face it !
RM3sh

venu reddy

unread,
Oct 31, 2012, 6:56:40 AM10/31/12
to flex_...@googlegroups.com, madhugee...@gmail.com
Hi,
There is an open source component CanvasButtonAccordionHeader in Flexlib library.All you need to do is download the source code or swc and use it in flex.
Below is the site for the documentation with an example



Let me know for any additional help .

Thanks,
Venu

On Sat, Oct 27, 2012 at 8:29 AM, madhavi chinni <madhugee...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To view this discussion on the web visit https://groups.google.com/d/msg/flex_india/-/W5c8DsWWXigJ.
To post to this group, send email to flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.



--
Venu Reddy

madhavi chinni

unread,
Oct 30, 2012, 4:55:49 AM10/30/12
to flex_...@googlegroups.com
Could you please tell me whether it worked in Flex3 or Flex4? In Flex3 it is working but not in Flex4 :(

Jameel Ahmad

unread,
Nov 1, 2012, 3:36:51 AM11/1/12
to flex_...@googlegroups.com
Hi,
I got the error in the code. You have used like this                                                                                                             this.addEventListener(MouseEvent.CLICK,showHeader);  //it hooks eventListener to CustomAccordionHeader
But you have to do is hook the button click eventListener to the button extraButton.
You should write like this in the createChildren method
extraButton.addEventListener(MouseEvent.CLICK,showHeader);

If still it doesn't work I may have to check your CustomButton class.

Regards,
Jameel.
Reply all
Reply to author
Forward
0 new messages