Reading Menu Data From XML

Do you know what’s the problem with my function that I’m not able to print the fetched Xml value outside of the function? See the Trace commands with the comments.

Thank you.

function fetchMainMenuData() {
    
    var my_xml:XML = new XML();
    my_xml.ignoreWhite = true;
    my_xml.load("mainMenu.xml");
    my_xml.onLoad = function(success:Boolean) {
        if (success) 
        {
            if (!root) { var root:XMLNode = my_xml.firstChild; }
            if (!lines) { var lines:Array = root.childNodes; }

            for (i=0; i<lines.length; i++)
                {
                    if (!itemNameEn) { var itemNameEn:Array = new Array(); }
                    itemNameEn* = my_xml.firstChild.childNodes*.childNodes[0].childNodes[0].nodeValue; 
                    trace (itemNameEn); // THIS LINE PRODUCES CORRECT OUTPUT.
                }
        }

        else trace ("Error");
    }
}

fetchMainMenuData();
trace (itemNameEn[1]); // THIS LINE DOES NOT PRODUCE WISHED OUTPUT.

AS2

If you define a data type within a function, the variable is then within scope of that function, and you cannot call the variable from somewhere else. Do not define itemNameEn as an array within the function - put it on the main timeline