# How to use varible inside function elsewhere?

**URL:** <https://forum.kirupa.com/t/how-to-use-varible-inside-function-elsewhere/223655>\
**Category:** flash\
**Created:** [April 24, 2007, 5:51pm UTC](https://forum.kirupa.com/t/how-to-use-varible-inside-function-elsewhere/223655 "2007-04-24T17:51:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![erebore](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@erebore](https://forum.kirupa.com/u/erebore)\
**Post date:** [April 24, 2007, 5:51pm UTC](https://forum.kirupa.com/t/how-to-use-varible-inside-function-elsewhere/223655/1 "2007-04-24T17:51:08Z")

</div>

Hello,

This is a newbie question (and so am I) but i havn´t found the answer anywhere and I would gladly appreciate som help!

This is what I am trying to do:

function loadXML(loaded) {  
if (loaded) {  
xmlNode = this.firstChild;  
image = [];  
description = [];  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++) {  
[COLOR=Red] image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
description\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
p = image\*;[/COLOR]  
}  
firstImage();  
} else {  
content = “file not loaded!”;  
}  
}

[COLOR=Red]trace§

[COLOR=Black]how come p is undefined? is there a way to make the variable global and useable outside the function?

I am basically trying to use the tutorial for loading external pictures from an XML file found here on kirupa, and get it to assign a number to every picture and load the latest addition.

So when a PHP program updates the XML file, the flash will load that latest added picture.

Thank you very much for your help and time!  
[/COLOR][/COLOR]
