Failure in executing a method [as 2.0]

Hi,

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


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

are you using something.onLoad = myOnload ?

Yes,


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

I just posted this earlier today, it should help:

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

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 :frowning: Do you have a suggestion?

use another method provided

Hmm I changed my code to this:


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

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

… then looks like its whats behind option #3!

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

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


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 :slight_smile:

Thats basically #1.