# Failure in executing a method \[as 2.0\]

**URL:** <https://forum.kirupa.com/t/failure-in-executing-a-method-as-2-0/119850>\
**Category:** Uncategorized\
**Created:** [August 18, 2004, 3:15pm UTC](https://forum.kirupa.com/t/failure-in-executing-a-method-as-2-0/119850 "2004-08-18T15:15:58Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![icestream](https://avatars.discourse-cdn.com/v4/letter/i/e19adc/32.png) [@icestream](https://forum.kirupa.com/u/icestream)\
**Post date:** [August 18, 2004, 3:15pm UTC](https://forum.kirupa.com/t/failure-in-executing-a-method-as-2-0/119850/1 "2004-08-18T15:15:58Z")

</div>

Hi,

I have a problem with executing a method called handleXML.  
At the moment I have the following code:

```auto

private function myOnload(success:Boolean):Void
	{
		trace("In myOnload");
			if(success)
			{
				trace("In myOnload -> success");
				handleXML(0);
			}
			else 
			{
				_root.info.text = "Failed to open Playlist.xml";
			}
	}
	
	public function handleXML(newSong:Number):Void
	{
		trace("In handleXML");
		var rootElement = myXML.firstChild;

```

Flash traces the following:  
In myOnload  
In myOnload -\> success

That means that for some reason the calling the handleXML method failed. Does someone know what is wrong with my code?

thnx

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [August 18, 2004, 3:17pm UTC](https://forum.kirupa.com/t/failure-in-executing-a-method-as-2-0/119850/2 "2004-08-18T15:17:50Z")

</div>

are you using something.onLoad = myOnload ?

---

<div class="post-metadata">

**Author:** ![icestream](https://avatars.discourse-cdn.com/v4/letter/i/e19adc/32.png) [@icestream](https://forum.kirupa.com/u/icestream)\
**Post date:** [August 18, 2004, 3:20pm UTC](https://forum.kirupa.com/t/failure-in-executing-a-method-as-2-0/119850/3 "2004-08-18T15:20:02Z")

</div>

Yes,

```auto

function MP3Player()
	{
		trace("New MP3Player");
		
		mySound = new Sound();
		
		myXML = new XML();
		myXML.ignoreWhite = true;
		
		myXML.onLoad = myOnload;
		myXML.load(XMLFILE);
	}

```

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [August 18, 2004, 3:25pm UTC](https://forum.kirupa.com/t/failure-in-executing-a-method-as-2-0/119850/4 "2004-08-18T15:25:25Z")

</div>

I just posted this earlier today, it should help:

[http://www.senocular.com/news.php?subaction=showcomments&id=1092856365](http://www.senocular.com/news.php?subaction=showcomments&id=1092856365)

---

<div class="post-metadata">

**Author:** ![icestream](https://avatars.discourse-cdn.com/v4/letter/i/e19adc/32.png) [@icestream](https://forum.kirupa.com/u/icestream)\
**Post date:** [August 18, 2004, 3:42pm UTC](https://forum.kirupa.com/t/failure-in-executing-a-method-as-2-0/119850/5 "2004-08-18T15:42:17Z")

</div>

Nice article! I have read it and it helped me allot but, I want to call a method and not an instance variable. So myXML[“var”] = var; won’t help ☹ Do you have a suggestion?

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [August 18, 2004, 3:45pm UTC](https://forum.kirupa.com/t/failure-in-executing-a-method-as-2-0/119850/6 "2004-08-18T15:45:25Z")

</div>

use another method provided

---

<div class="post-metadata">

**Author:** ![icestream](https://avatars.discourse-cdn.com/v4/letter/i/e19adc/32.png) [@icestream](https://forum.kirupa.com/u/icestream)\
**Post date:** [August 18, 2004, 3:55pm UTC](https://forum.kirupa.com/t/failure-in-executing-a-method-as-2-0/119850/7 "2004-08-18T15:55:44Z")

</div>

Hmm I changed my code to this:

```auto

import mx.utils.Delegate;

class MP3Player 
{
....
function MP3Player()
	{
		trace("New MP3Player");
		
		mySound = new Sound();
		
		myXML = new XML();
		myXML.ignoreWhite = true;
		
		myXML.onLoad = Delegate.create(this, onLoadEvent);
		myXML.load(XMLFILE);
	}
	
	private function onLoadEvent(success:Boolean):Void
	{
		trace("In myOnload");
			if(success)
			{
				trace("In myOnload -> success");
				handleXML(0);
			}
			else 
			{
				_root.info.text = "Failed to open Playlist.xml";
			}
	}

```

But now flash show this error: There is no method with the name ‘Delegate’. :s

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [August 18, 2004, 4:04pm UTC](https://forum.kirupa.com/t/failure-in-executing-a-method-as-2-0/119850/8 "2004-08-18T16:04:34Z")

</div>

I take it you aren’t using Flash MX 2004 7.2?

… then looks like its whats behind option #3!

---

<div class="post-metadata">

**Author:** ![icestream](https://avatars.discourse-cdn.com/v4/letter/i/e19adc/32.png) [@icestream](https://forum.kirupa.com/u/icestream)\
**Post date:** [August 18, 2004, 5:11pm UTC](https://forum.kirupa.com/t/failure-in-executing-a-method-as-2-0/119850/9 "2004-08-18T17:11:02Z")

</div>

I solved the problem, but different from the ones you gave me 🙂

I’d place the function with the onload method in the fla file on the first frame.

```auto

var myMP3Player:MP3Player = new MP3Player();

function onLoadXML(success:Boolean):Void
{
	trace("In myOnload");
		if(success)
		{
			trace("In myOnload -> success");
			myMP3Player.handleXML(0);
		}
		else 
		{
			_root.info.text = "Failed to open Playlist.xml";
		}
}

```

And when handleXML must be called I call it with the instance of the class mp3player I created 🙂

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [August 18, 2004, 5:44pm UTC](https://forum.kirupa.com/t/failure-in-executing-a-method-as-2-0/119850/10 "2004-08-18T17:44:08Z")

</div>

Thats basically #1.
