Knowledge Base |
Important! All new questions are usually answered within the next business day.
Accordion (Tree) Menu V3
(views: 7272)
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: 1224)
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.
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
var acc:AccordionTreeMenuV3AS3;
//create a listener, to find when the button is pressed
buttonOne.addEventListener(MouseEvent.MOUSE_DOWN, buttonOnePress)
function buttonOnePress(event:MouseEvent)
{
// 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)
{
// 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 the width of it (initial is 100).
acc.width = 200
//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);
}
import flash.events.MouseEvent
var acc:AccordionTreeMenuV3AS3;
//create a listener, to find when the button is pressed
buttonOne.addEventListener(MouseEvent.MOUSE_DOWN, buttonOnePress)
function buttonOnePress(event:MouseEvent)
{
// 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)
{
// 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 the width of it (initial is 100).
acc.width = 200
//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);
}
User Comments
runtime add AccordianTreeMenuV3 for AS2?
Can you show an example of how to add the AccordianTreeMenuV3 AS2 version of the component at runtime ? Many thanks....I didn't see an example yet.
posted by W on 2007-11-14
Can you show an example of how to add the AccordianTreeMenuV3 AS2 version of the component at runtime ? Many thanks....I didn't see an example yet.
AS2 version
W
Se this :P
<a href='https://www.jumpeyecomponents.com/knowledgebase/Accordion-%28Tree%29-Menu-V3/How-do-I-add-the-AccordionTreeMenuV3-on-stage-in-runtime%3F~181/'>here</a>
posted by demiurgu on 2007-11-15
W
Se this :P
<a href='https://www.jumpeyecomponents.com/knowledgebase/Accordion-%28Tree%29-Menu-V3/How-do-I-add-the-AccordionTreeMenuV3-on-stage-in-runtime%3F~181/'>here</a>
Answer for jbmurphy
Hi
You should use setXML(xmlObject:XML) method .
After you've added the component, instead of using the xmlPath parameter:
acc.xmlPath = xm;
you have to write this :
acc.setXML(xmlObject) where xmlOject is your xml object
posted by demiurgu on 2007-11-15
Hi
You should use setXML(xmlObject:XML) method .
After you've added the component, instead of using the xmlPath parameter:
acc.xmlPath = xm;
you have to write this :
acc.setXML(xmlObject) where xmlOject is your xml object
That worked well, thank you.
Just a quick note for anyone who uses the component as I have, make sure that when you are creating an XML object in your class file that you give a "title" attribute to each item node, even if it's title="", otherwise you will get a setText() error.
posted by jbmurphy on 2007-11-15
Just a quick note for anyone who uses the component as I have, make sure that when you are creating an XML object in your class file that you give a "title" attribute to each item node, even if it's title="", otherwise you will get a setText() error.
perfectly true
That's right
Thanks for bringing this to our attention. We will fix it in the next release :)
posted by demiurgu on 2007-11-16
That's right
Thanks for bringing this to our attention. We will fix it in the next release :)
can i load .swfs into each XML node?
I bought this for a very specific project. The nav uses Arial and needs to have a significant amount of letter spacing. Your answer to my last question was that letter kerning was not possible with this component - with no solution. How can I work around this? could i load .swfs into each XML node? Can I alter anything with actionscript in the movie the component is loaded into? The beauty of working in flash is that nothing has to look like html anymore. I need a solution, please help!
posted by acillustration on 2008-02-13
I bought this for a very specific project. The nav uses Arial and needs to have a significant amount of letter spacing. Your answer to my last question was that letter kerning was not possible with this component - with no solution. How can I work around this? could i load .swfs into each XML node? Can I alter anything with actionscript in the movie the component is loaded into? The beauty of working in flash is that nothing has to look like html anymore. I need a solution, please help!
Login to post your comment
Other questions in this item:
Call JavaScript from XML Open menu item pages into target - "_self" Transparent background menu Use hand cursor on menu Item description from XML Can I add a rollover sound? Go to different frames by pressing a menu item Scene navigation Referencing item's textfield in Accordion (Tree) Menu V3 Animated items Keep the Accordion (Tree) Menu V3 vertically aligned Disable-Enable Accordion (Tree) Menu V3 Adding icons Load movies on item select Add different styles for each main items. how to change fontsize Underline On Rollover Selected item level Add a fixed item under the menu Autoexpand on Start Get the type of the selected item Children of a menu item How do I add the AccordionTreeMenuV3 on stage in runtime? acc.height not updated? Change Text Color on Rollover Automatic Collapse hotwo: submenus already expanded on activation? Letter kerning Align header text to right Insert a line break into label Go To First Child When Select Top Level Menu Item Reference to text fields within menu items Change the position of the menu icons Change the position of the folder icons Open menu upwards Spacing between menu items Step backwards and forwards through menu Rotated text for menu items Use hand cursor on menu Accordion Tree Menu expandAll() clickItem() and expandItem() do not execute actions of menu item Accordion menu accurate size Menu Item visibility / disable Letter kerningMenu |
|
|


I sincerely hope this is possible, but it might not be which would render this component useless for me in this application, but ... instead of an actual physical xml file I have an xml object that I have created through actionscript that traces out exactly as this component requires.
Please tell me that it is possible to do this with this component.