Hi hard_overclocker!!
Thank you very much for your menu tree source, I understand some things, but Iīm still confused with others... :(
Hope we could have a tutorial on how to do this xml menu tree soon here. :)
It will be fantastic!!
Well first o all Iīm not repeating my first post. I just want to understand somethings so I will post my original code using xmlList (sorry Flep! :P - this code works perfect with your code too!) and would like a help on how to add a tween effect when the Top level item was clicked. For example: if top level 1 is clicked, all the others top levels "y" property will change (with tween effect) according to the length of the subitems of the top level 1. And so on for the others top levels.
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
var menuText:TextField;
var menuSubText:TextField = new TextField;
var myTween:Tween;
var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("xml/clientesBrasil.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(event:Event):void
{
xml = XML(event.target.data);
xmlList = xml.children();
for (var i:int = 0; i < xmlList.length(); i++)
{
menuText = new TextField();
menuText.y = i * 20;
menuText.text = xmlList[i].attribute("TIPO");
menuText.name = xmlList[i].attribute("TIPO");
menuText.autoSize = TextFieldAutoSize.LEFT;
addChild(menuText);
menuText.addEventListener(MouseEvent.CLICK, onClick);
}
}
function onClick(event:MouseEvent):void
{
for (var j:int = 0; j < xmlList.length(); j++)
{
menuSubText.x = 200;
menuSubText.autoSize = TextFieldAutoSize.LEFT;
addChild(menuSubText);
if (xmlList[j].attribute("TIPO") == event.target.name)
{
menuSubText.text = xmlList[j].children();
myTween = new Tween (menuText, "y", Strong.easeOut, menuText.y, menuSubText.height, 1, true);
}
}
}
If you could test this code using the xml file I post in the first post, you will see that the "y" tween effect itīs woking, but only the last top level change the "y" property (MENU 4). Itīs really necessary to use arrays to apply this tween effect to the others top levels items?
Iīm asking this because if you remove the tween effect, and test the movie, you will see that the menu works fine, top level clicked shows the correct subitem.
Iīm not an expert on AS3, but i imagine itīs kind simple to do this, but itīs not working...:(
Hope I explanated what is confusing me.
Again, I would like to thank for all your help!!
By!!