Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

XML menu tree

This is a discussion on XML menu tree within the advanced Actionscript 3.0 forums, part of the Flash CS3 eng category; Hi Flep! After reading your tutorial about arrays and reading the multiple gallery xml Slideshow topic again, I begin to ...


Go Back   Forum Flash CS3 Flash CS4 > English Forums > Flash CS3 eng > advanced Actionscript 3.0

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 15-12-07, 15:22
Junior Member
 
Join Date: Aug 2007
Location: Brasil
Posts: 18
Rep Power: 0
Magdy is on a distinguished road
Re: XML menu tree

Hi Flep!

After reading your tutorial about arrays and reading the multiple gallery xml Slideshow topic again, I begin to understand the need of arrays for this type of thing I want to do. Thank you very much for the help!

Now I have another doubt. Using your example with the multiple gallery xml Slideshow, in the end of the code, you trace two arrays:

Code:
trace(my_array[3][2]);
At this point, everything is fine!

Still using your example, If I try to trace this:
Code:
trace(my_array[i][j]);
I get a Value, still working!!
When I try to trace the same thing [i][j] using my xml code, the output show me undefined.

I'm posting my AS3 code and the xml code is the same as the first post:
Code:
var menuArray:Array = new Array();

var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("arrays.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

function xmlLoaded(event:Event):void
{
    var xmlLoader:URLLoader = URLLoader(event.target);
    var xml:XML = new XML(xmlLoader.data);
    var myXML:XMLDocument = new XMLDocument();
    myXML.ignoreWhite = true;
    myXML.parseXML(xml.toXMLString());
    var node:XMLNode = myXML.firstChild;

    var itemArray:Array = new Array;
    for (var i:int = 0; i < node.childNodes.length; i++)
    {
        itemArray.push(node.childNodes[i].attributes['NOME']);

        var itemSubArray:Array = new Array();
        var s:int = node.childNodes[i].childNodes.length;
        for (var j:int = 0; j < s; j++)
        {
            itemSubArray.push(node.childNodes[i].childNodes[j].firstChild.nodeValue);
        }
        menuArray.push(itemSubArray);
    }
    menuArray.push(itemArray);
    trace(menuArray[i][j]);
}
What is wrong? is the same as file, I only changed the array names.
If I trace this everything goes fine:
Code:
trace(my_array[3][2]);
By the way, I tried to add the top level menu itens and everything works fine, but I'm having problem to add the sub itens when the top level menu is clicked.

There's to many thing to understand...
Hope to get an answer from you soon!!!

Bye!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #12 (permalink)  
Old 15-12-07, 16:01
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,486
Rep Power: 6
Flep is on a distinguished road
Re: XML menu tree

Hi Magdy,

I have another sample for you. The topic is italian, but you can download the rar file in the last post and have a look at the code.

Otherwise, attach your files and I will have a look
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #13 (permalink)  
Old 15-12-07, 17:24
Junior Member
 
Join Date: Aug 2007
Location: Brasil
Posts: 18
Rep Power: 0
Magdy is on a distinguished road
Re: XML menu tree

What´s the name of the topic?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #14 (permalink)  
Old 15-12-07, 17:35
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,486
Rep Power: 6
Flep is on a distinguished road
Re: XML menu tree

ops.... sorry

http://www.flepstudio.org/forum/util...li-da-xml.html
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #15 (permalink)  
Old 15-12-07, 17:46
Junior Member
 
Join Date: Aug 2007
Location: Brasil
Posts: 18
Rep Power: 0
Magdy is on a distinguished road
Re: XML menu tree

Thanks!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Flash Multi Gallery
  #16 (permalink)  
Old 15-12-07, 21:20
Junior Member
 
Join Date: Aug 2007
Location: Brasil
Posts: 18
Rep Power: 0
Magdy is on a distinguished road
Re: XML menu tree

Hi Flep!!

man I'm sorry, this is getting difficult to me...
I saw the code, from the other sample but it makes me more confused... there´s many arrays and pushes.

I want to learn by my self but it's hard... I don't want you to do for me.

I will try again at night, take a look at the other code again...
It's almost a week trying to understand this... hehehe
crazy stuff

Well that's it for now
Bye
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #17 (permalink)  
Old 20-12-07, 17:20
Junior Member
 
Join Date: Aug 2007
Location: Brasil
Posts: 18
Rep Power: 0
Magdy is on a distinguished road
Re: XML menu tree

Hi Flep!!

I'm still working with this menu tree (accordion menu)...
I want to know what to do... I think I need an if condition that will listen to what is clicked in the first top level so after the click it will show the proper sub item. Where to add this if condition? after the second for loop?
Where I add the button function?

The code:
Code:
var menuArray:Array = new Array();
var menuText:TextField;
var menuSubText:TextField = new TextField();

var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("arrays.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

function xmlLoaded(event:Event):void
{
    var xml:XML = new XML(event.target.data);
    var myXML:XMLDocument = new XMLDocument();
    myXML.ignoreWhite = true;
    myXML.parseXML(xml.toXMLString());
    var node:XMLNode = myXML.firstChild;

    var itemArray:Array = new Array();
    var firstNode:int = node.childNodes.length;
    for (var i:int = 0; i < firstNode; i++)
    {
        itemArray.push(node.childNodes[i].attributes['NOME']);
        menuText = new TextField();
        menuText.y = i * 20;
        menuText.text = itemArray[i];
        menuText.autoSize = TextFieldAutoSize.LEFT;
        addChild(menuText);
        menuText.addEventListener(MouseEvent.CLICK, onClick);

        var itemSubArray:Array = new Array();
        var secondNode:int = node.childNodes[i].childNodes.length;
        for (var j:int = 0; j < secondNode; j++)
        {
            itemSubArray.push(node.childNodes[i].childNodes[j].firstChild.nodeValue);
        }
        menuArray.push(itemSubArray);
    }
    menuArray.push(itemArray);
    function onClick(event:MouseEvent):void
    {
        trace(menuArray[0][0]);
    }
}
Really need help on this!!
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #18 (permalink)  
Old 21-12-07, 05:55
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,486
Rep Power: 6
Flep is on a distinguished road
Re: XML menu tree

Write here the XML too please.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #19 (permalink)  
Old 21-12-07, 17:20
Junior Member
 
Join Date: Aug 2007
Location: Brasil
Posts: 18
Rep Power: 0
Magdy is on a distinguished road
Re: XML menu tree

AS3 Code:
Code:
var menuArray:Array = new Array();
var menuText:TextField;
var menuSubText:TextField = new TextField();

var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("arrays.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

function xmlLoaded(event:Event):void
{
    var xml:XML = new XML(event.target.data);
    var myXML:XMLDocument = new XMLDocument();
    myXML.ignoreWhite = true;
    myXML.parseXML(xml.toXMLString());
    var node:XMLNode = myXML.firstChild;

    var itemArray:Array = new Array();
    var firstNode:int = node.childNodes.length;
    for (var i:int = 0; i < firstNode; i++)
    {
        itemArray.push(node.childNodes[i].attributes['NOME']);
        menuText = new TextField();
        menuText.y = i * 20;
        menuText.text = itemArray[i];
        menuText.autoSize = TextFieldAutoSize.LEFT;
        addChild(menuText);
        menuText.addEventListener(MouseEvent.CLICK, onClick);

        var itemSubArray:Array = new Array();
        var secondNode:int = node.childNodes[i].childNodes.length;
        for (var j:int = 0; j < secondNode; j++)
        {
            itemSubArray.push(node.childNodes[i].childNodes[j].firstChild.nodeValue);
        }
        menuArray.push(itemSubArray);
    }
    menuArray.push(itemArray);
    function onClick(event:MouseEvent):void
    {
        trace(menuArray[0][0]);
    }
}
XML:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<CB>
    <TC NOME="MENU1">
        <CT>MENU1/SUBMENU1</CT>
        <CT>MENU1/SUBMENU2</CT>
    </TC>
    <TC NOME="MENU2">
        <CT>MENU2/SUBMENU1</CT>
        <CT>MENU2/SUBMENU2</CT>
        <CT>MENU2/SUBMENU3</CT>
        <CT>MENU2/SUBMENU4</CT>
        <CT>MENU2/SUBMENU5</CT>
        <CT>MENU2/SUBMENU6</CT>
    </TC>
    <TC NOME="MENU3">
        <CT>MENU3/SUBMENU1</CT>
        <CT>MENU3/SUBMENU2</CT>
        <CT>MENU3/SUBMENU3</CT>
        <CT>MENU3/SUBMENU4</CT>
    </TC>
    <TC NOME="MENU4">
        <CT>MENU4/SUBMENU1</CT>
        <CT>MENU4/SUBMENU2</CT>
        <CT>MENU4/SUBMENU3</CT>
        <CT>MENU4/SUBMENU4</CT>
        <CT>MENU4/SUBMENU5</CT>
        <CT>MENU4/SUBMENU6</CT>
        <CT>MENU4/SUBMENU7</CT>
    </TC>
</CB>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #20 (permalink)  
Old 31-12-07, 18:56
Junior Member
 
Join Date: Aug 2007
Location: Brasil
Posts: 18
Rep Power: 0
Magdy is on a distinguished road
Re: XML menu tree

Hi flep!!

Any help on this thread?
Still stuck on this...

Well, Happy New Year to you all!!
Bye
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Load directory structure in tree component fisad Flash CS3 eng 0 17-04-08 23:08
menu tree ad albero in su sk8benji Flash CS3 generale 2 01-04-08 13:45
[propagazione di eventi] menu tree pepigno75 Actionscript 3.0 avanzato 2 24-03-08 14:42


All times are GMT. The time now is 22:34.


Powered by vBulletin versione 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap


FlepStudio
by Filippo Lughi
P.IVA 03605860406