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
system
August 18, 2004, 3:17pm
2
are you using something.onLoad = myOnload ?
system
August 18, 2004, 3:20pm
3
Yes,
function MP3Player()
{
trace("New MP3Player");
mySound = new Sound();
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = myOnload;
myXML.load(XMLFILE);
}
system
August 18, 2004, 3:25pm
4
system
August 18, 2004, 3:42pm
5
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?
system
August 18, 2004, 3:45pm
6
use another method provided
system
August 18, 2004, 3:55pm
7
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
system
August 18, 2004, 4:04pm
8
I take it you aren’t using Flash MX 2004 7.2?
… then looks like its whats behind option #3 !
system
August 18, 2004, 5:11pm
9
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.
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