# Problem with calling functions & XML

**URL:** https://forum.kirupa.com/t/problem-with-calling-functions-xml/185986
**Category:** flash
**Created:** [April 18, 2006, 8:46am UTC](https://forum.kirupa.com/t/problem-with-calling-functions-xml/185986 "2006-04-18T08:46:20Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![liquidFusion](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@liquidFusion](https://forum.kirupa.com/u/liquidFusion)
#### Post date: [April 18, 2006, 8:46am UTC](https://forum.kirupa.com/t/problem-with-calling-functions-xml/185986/1 "2006-04-18T08:46:20Z")

</div>

I’m making a dynamic speedometer in Flash8 - AS2.0, using XML as my datasource. I get to load the XML doc just fine, manipulate the data and so on, but for some reason I cannot get my XML function to call another function. :stunned:

I’ve added a GIF explaining what I’m trying to do. Please have a look at it as it also holds the code as a whole.

Any ideas why this doesn’t work? I can call the calcDegree function (or any other functions for that matter) from every other function or from the constructor function.

Any clues?

---

<div class="post-metadata">

### Author: ![theflash](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/theflash/32/1221_2.png) [@theflash](https://forum.kirupa.com/u/theflash)
#### Post date: [April 18, 2006, 8:58am UTC](https://forum.kirupa.com/t/problem-with-calling-functions-xml/185986/2 "2006-04-18T08:58:47Z")

</div>

Because the scope is not getXML class… the time you execute this

xmlData.onLoad = xmlLoad;

when executed on this event scope in xmlLoad function will be xmlData because that function is assigned to the event of xmlData object…

you will have to use Delegate to make xmlLoad in the scope of your own class (getXML)

```
ActionScript Code:
[FONT=Courier New][LEFT]xmlData.[COLOR=#0000FF]onLoad[/COLOR] = Delegate.[COLOR=#000080]create[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]this[/COLOR], xmlLoad[COLOR=#000000])[/COLOR];

```

[/LEFT]  
[/FONT]

---

<div class="post-metadata">

### Author: ![theflash](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/theflash/32/1221_2.png) [@theflash](https://forum.kirupa.com/u/theflash)
#### Post date: [April 18, 2006, 9:00am UTC](https://forum.kirupa.com/t/problem-with-calling-functions-xml/185986/3 "2006-04-18T09:00:44Z")

</div>

Because the scope is not getXML class… the time you execute this

xmlData.onLoad = xmlLoad;

scope in xmlLoad function will be xmlData because that function is assigned to the event of xmlData object…

you will have to use Delegate to make xmlLoad in the scope of your own class (getXML)

xmlData.onLoad = Delegate.create(this, xmlLoad);

---

<div class="post-metadata">

### Author: ![liquidFusion](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@liquidFusion](https://forum.kirupa.com/u/liquidFusion)
#### Post date: [April 18, 2006, 10:00am UTC](https://forum.kirupa.com/t/problem-with-calling-functions-xml/185986/4 "2006-04-18T10:00:17Z")

</div>

Thanks a million times!! :p:  
Kirupa actually has a read up on this subject too: [http://www.kirupa.com/web/xml/XMLspecificIssues3.htm](http://www.kirupa.com/web/xml/XMLspecificIssues3.htm)

Anyway! Thanks again. Works like a charm now!  
Have a good day.

---

<div class="post-metadata">

### Author: ![theflash](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/theflash/32/1221_2.png) [@theflash](https://forum.kirupa.com/u/theflash)
#### Post date: [April 18, 2006, 10:25am UTC](https://forum.kirupa.com/t/problem-with-calling-functions-xml/185986/5 "2006-04-18T10:25:06Z")

</div>

Welcome 🙂 great to hear that…
