# Call function with variable in XML

**URL:** <https://forum.kirupa.com/t/call-function-with-variable-in-xml/271406>\
**Category:** flash\
**Created:** [September 22, 2008, 8:24pm UTC](https://forum.kirupa.com/t/call-function-with-variable-in-xml/271406 "2008-09-22T20:24:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![log](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@log](https://forum.kirupa.com/u/log)\
**Post date:** [September 22, 2008, 8:24pm UTC](https://forum.kirupa.com/t/call-function-with-variable-in-xml/271406/1 "2008-09-22T20:24:31Z")

</div>

Hi,

Hopefully somebody can help me.

How can I call a function in Flash MX that has a variable, in XML?

To call a function in Flash with XML, you just need to put the name of the function without brackets.  
e.g.:

```
Code:
[LEFT] 

```

**XML**  
\< tagXML \> MyFunction \< / tagXML\> //this works  
\< tagXML \> MyFunction() \< / tagXML\> //this doesn’t work

**Flash**  
MyVar = Tag.childNodes[0].firstChild.nodeValue;  
MyText.text = MyVar

function MyFunction() {  
var cText = “Hello World”  
return cText  
}[/LEFT]

My question is now? How do I have to call a function with a variable?  
Which text do I have to write in my XML between the tags, to make this work.  
I can’t add an extra tag for the variable in my XML, because this would change my structure of my XML file, it has to be possible in one tag to call the function with a variable.

e.g.:  
Code:  
[LEFT] **XML**  
\< tagXML \> MyFunction(“Hello World”) \< / tagXML \> //this doesn’t work:(

**Flash**  
MyVar = TagXML.childNodes[0].firstChild.nodeValue;  
MyText.text = MyVar

function MyFunction(cText) {  
return cText;  
};[/LEFT]

possi
