Hi ;),
i have a problem with my project in OOP : i try to create a mp3 player with the OOP construction, but i have an error message when i try to call the get or set function of another class inside my project.
Could you please help me?
i have my class “client” : to instanciate :
public function Client(){
var xml:XMLCharge = new XMLCharge("mp3.xml");
var lecteur:Lecteur = new Lecteur( xml );
}
my class “XMLCharge” to deal with the xml data :
public function XMLCharge(pData:String):void {
xmlURL = pData;
my class “Lecteur” to create a first class for the player : and use the parameter xmlCharge which is >> new XMLCharge(“mp3.xml”); :
public class Lecteur extends Sprite {
var _xmlCharge : XMLCharge;
public function Lecteur(xmlCharge) {
_xmlCharge = xmlCharge;
}
}
and my class with the buttons of the mp3 player : boutonsMp3.as :
public class BoutonsMp3 extends Lecteur //to have the same parameter as the class "Lecteur"
...
public function BoutonsMp3 (xml:XMLCharge) {
super (xml);
i try now to call the get or set function which is inside my class “XMLCharge.as”. so i try this in the boutonsMp3.as class:
xml.songArray.id
but i have a problem, they say “xml non declared”, but xml is my parameter and i want to call the get function like that, how can i proceed?
Here is the get function in XMLCharge.as ::
public function get songArray():Array {
return _songArray;
}
, and “_songArray” is an array containing an instance of the class “Model” , where there are all the getters and setters of the xml file. I have a loop like that to fill the array :
for (var j:int=0; j<chansonTotal; j++) {
m = new Model;
m.lien = xmlLien[j];
m.titre = xmlTitre[j];
m.id = xmlID[j];
_songArray.push (m);
}
Basically, i’d like to call the “next song” when i press the “next song” button, so i’d like to call the class with all my data, and tell it “read now the next song” :
xml.songArray[nextIndex].title
-xml is here to call the class XMLCharge.as where my get and set function are
-songArray is the setter,
-current is the variable with the new song, so i’ll have the index songArray[current], to reach therefore the “instance of Model” where all my xml data is
- and title is the get function inside the class Model…
i hope you’re still there … i really need some help, where my code is wrong, what do i have to change, to make it work as a OOP project…
Thank you very much for any answer
I put all my classes in a zip file.
Thanks