My account
Shopping cart
Knowledge base
Support

Knowledge Base

Important! All new questions are usually answered within the next business day.

Accordion (Tree) Menu V3

(views: 35577)

Accordion Menu V3 and Accordion Tree Menu V3 are xml flash accordion menus featuring customized states, customized transitions and tweens. Here are all known issues for Accordion Menu V3 and Accordion Tree Menu V3, they should be similar, since basically it is the same component. If you have any questions that you think we should discuss here please let us know.



How do I add the AccordionTreeMenuV3AS3 from class file to stage

(2007-11-14 - views: 13758)
Q: I'm sure this is possible but I am just learning AS3 and I need to be able to add this component to the stage with a button click, passing in a variable that contains the xml for the menu. I have parsed a huge xml file in my class file and have broken it down into 4 new xml objects with each xml object being the navigation for each of the 4 buttons I have.

So for example I have a button on stage called "buttonOne". I also have an XML object called "buttonOneXML". I would like to add the AccordionTreeMenuV3AS3 to the stage when "buttonOne" is pressed and tell it to use "buttonOneXML" as it's source.

Please help, this is a fairly urgent request and I cannot find any documentation on adding the component at run-time.

A: Here is the script you have to adapt to your project.

import flash.events.MouseEvent;
import com.jumpeye.Events.AccordionMenuEvents;

var acc:AccordionTreeMenuV3AS3;

//create a listener, to find when the button is pressed
buttonOne.addEventListener(MouseEvent.MOUSE_DOWN, buttonOnePress);
function buttonOnePress(event:MouseEvent):void
{
    // when the button is pressed, we call de attachMenu function to create another AccordionTreeMenuV3AS3
    attachMenu("buttonOneXML.xml");
}
// the function that attach a new AccordionTreeMenuV3AS3.
function attachMenu(xm:String):void
{
    // if another menu already exist, we remove it.
    if(acc != null)
        this.removeChild(acc);
   
    // we create the menu.
    acc = new AccordionTreeMenuV3AS3();
    // set the xml for the menu.
    acc.xmlPath = xm;
   
    //we  set a random position, to know that a new menu was created.
    acc.x = Math.random()*350;
   
    //and finaly, we add the menu on the stage.
    this.addChild(acc);
   
    // we need to know when the menu has finished drawing itself on the stage,
    // because only than can we set the width property (which does not exist
    // until then).
    acc.addEventListener(AccordionMenuEvents.DRAW, drawHdl);
}

// after the entire component has been drawn, we can set the width of the menu.
function drawHdl(evt:AccordionMenuEvents):void {
    acc.width = 200;
}


Back