# Can't access Flash labels through XML?

**URL:** <https://forum.kirupa.com/t/cant-access-flash-labels-through-xml/290816>\
**Category:** flash\
**Created:** [June 19, 2009, 10:12pm UTC](https://forum.kirupa.com/t/cant-access-flash-labels-through-xml/290816 "2009-06-19T22:12:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![EdThaSt0rm](https://avatars.discourse-cdn.com/v4/letter/e/919ad9/32.png) [@EdThaSt0rm](https://forum.kirupa.com/u/EdThaSt0rm)\
**Post date:** [June 19, 2009, 10:12pm UTC](https://forum.kirupa.com/t/cant-access-flash-labels-through-xml/290816/1 "2009-06-19T22:12:37Z")

</div>

Hello all!

I’m working in Flash with a XML menu.  
  
The idea is: when you click on a button from the XML menu it should take me to a **Label** in Flash.

I’m using the following CS3 code to call on the XML;

> 

//The path for the XML file  
[COLOR=Blue]var xmlPath:String = “menu.xml”;[/COLOR]

//We will store the loaded XML to this variable  
[COLOR=Blue]var xml:XML;[/COLOR]

//Create a loader and load the XML. Call the function “xmlLoaded” when done.  
[COLOR=Blue]var loader = new URLLoader();  
loader.load(new URLRequest(xmlPath));  
loader.addEventListener(Event.COMPLETE, xmlLoaded);[/COLOR]

//This function is called when the XML file is loaded  
[COLOR=Blue]function xmlLoaded(e:Event):void {[/COLOR]

```
//Make sure that we are not working with a null variable
[COLOR=Blue]if ((e.target as URLLoader) != null ) {[/COLOR]
    
    //Create a new XML object with the loaded XML data
    [COLOR=Blue]xml = new XML(loader.data);[/COLOR]
    
    //Call the function that creates the menu
    [COLOR=Blue]createMenu();
}[/COLOR]

```

}  
And when you click on one of the buttons:

> //This function is called when an item is clicked  
> [COLOR=Blue]function itemClicked(e:Event):void {[/COLOR]

```
//Get the item that dispatched the event
[COLOR=Blue]var item:MenuItem = e.target as MenuItem;
gotoAndPlay(item.linkTo);

```

}[/COLOR]  
The XML looks like this:

> \<menu\>

```
&lt;buttons&gt;

    &lt;button&gt;
        &lt;label&gt;Home&lt;/label&gt;
        &lt;linkTo&gt; **information** &lt;/linkTo&gt;
    &lt;/button&gt;
    &lt;button&gt;
        &lt;label&gt;About&lt;/label&gt;
        &lt;linkTo&gt; **about** &lt;/linkTo&gt;
    &lt;/button&gt;
    &lt;button&gt;

```

\</buttons\>  
\</menu\>

The bold words are the Label names I use in Flash. When you click on Home it should take you to the label _“Information”_, and when you click on About it should take you to the label _“about”_

How is it that am getting an error everytime I click on Home?

> [COLOR=Blue]TypeError: Error #1009: Cannot access a property or method of a null object reference.  
> at project\_fla::MainTimeline/enterFrameHandler()[/COLOR]  
> Can someone help me out here? Much appreciated.
