1 Reply Latest reply on Aug 4, 2008 7:57 AM by Newsgroup_User

    Overriding Accordion Behavior

    katychapman85 Level 1
      Does anyone know how I can override the behaviour of the Accordion Menu.

      At the moment I have an Accordion Menu with 2 headers, I created these 2 function so that I can click on the header that is open and it will close itself and open the other header and the icons change accordingly depending on which header is open:

      private function AccordionCompleteHandler():void{
      var currentHeader:Button;
      for (var i:int = 0; i < document.AccordionMenu.numChildren; i++)
      {
      currentHeader = Button(document.AccordionMenu.getHeaderAt(i));
      currentHeader.addEventListener("click", headerClickHandler);
      }
      }

      [Embed(source='arrow_down.png')]
      [Bindable]
      public var arrowDown:Class;
      [Embed(source='arrow.png')]
      [Bindable]
      public var arrow:Class;

      private function headerClickHandler(event:MouseEvent):void{
      var header:Button = Button(event.target);
      var headerChild:Container = Container(IDataRenderer(header).data);
      if (headerChild == document.AccordionMenu.selectedChild)
      {
      if (document.AccordionMenu.selectedIndex == 0)
      {
      document.AccordionMenu.selectedIndex = 1;
      document.PaletteMenu.icon = arrowDown;
      document.ColoursMenu.icon = arrow;
      }else{
      document.AccordionMenu.selectedIndex = 0;
      document.PaletteMenu.icon = arrow;
      document.ColoursMenu.icon = arrowDown;
      }
      }
      }

      However, if I click on an unopened header it will open without changing the icons. Also when my application starts I don't want the user to be able to open the second header until a variable called PaletteSelected = true. Is there a way I can disable or override the Accordion behaviour so that I can get it to work how I want?

      Also does anyone know if it's possible to get the opened header to highlight when clicked like it does with an unopened header?

      Thanks
      Katy
        • 1. Re: Overriding Accordion Behavior
          Level 7

          "katychapman85" <webforumsuser@macromedia.com> wrote in message
          news:g76urg$ejk$1@forums.macromedia.com...
          > Does anyone know how I can override the behaviour of the Accordion Menu.
          >
          > At the moment I have an Accordion Menu with 2 headers, I created these 2
          > function so that I can click on the header that is open and it will close
          > itself and open the other header and the icons change accordingly
          > depending on
          > which header is open:
          >
          > private function AccordionCompleteHandler():void{
          > var currentHeader:Button;
          > for (var i:int = 0; i < document.AccordionMenu.numChildren; i++)
          > {
          > currentHeader = Button(document.AccordionMenu.getHeaderAt(i));
          > currentHeader.addEventListener("click", headerClickHandler);
          > }
          > }
          >
          > [Embed(source='arrow_down.png')]
          > [Bindable]
          > public var arrowDown:Class;
          > [Embed(source='arrow.png')]
          > [Bindable]
          > public var arrow:Class;
          >
          > private function headerClickHandler(event:MouseEvent):void{
          > var header:Button = Button(event.target);
          > var headerChild:Container = Container(IDataRenderer(header).data);
          > if (headerChild == document.AccordionMenu.selectedChild)
          > {
          > if (document.AccordionMenu.selectedIndex == 0)
          > {
          > document.AccordionMenu.selectedIndex = 1;
          > document.PaletteMenu.icon = arrowDown;
          > document.ColoursMenu.icon = arrow;
          > }else{
          > document.AccordionMenu.selectedIndex = 0;
          > document.PaletteMenu.icon = arrow;
          > document.ColoursMenu.icon = arrowDown;
          > }
          > }
          > }
          >
          > However, if I click on an unopened header it will open without changing
          > the
          > icons. Also when my application starts I don't want the user to be able to
          > open
          > the second header until a variable called PaletteSelected = true. Is there
          > a
          > way I can disable or override the Accordion behaviour so that I can get it
          > to
          > work how I want?
          >
          > Also does anyone know if it's possible to get the opened header to
          > highlight
          > when clicked like it does with an unopened header?

          I think you can write your own AccordionHeaderRenderer.

          I believe you can just set the enabled property on the child object of the
          Accordion to false to disable it.

          HTH;

          Amy