dtl27
06-25-2009, 11:25 AM
I'm basically doing a media player - using flvplayback, a free as2 medialist component (from afcomponents.com) and an XML file to populate the media list.
I then wanted to modify it to display the current track playing by using dynamic text.
I've got the info loaded into it fine but it only shows the information specified.
I think i need to make the "...this.firstChild.childNodes [0]..." variable so that when a new item is chosen from the media list the number "[0]" changes to the selected item number.
But that's where i get lost. I don't know if its possible or, if it is, how to do it.
I'm a real noob as they say, only had slash for like a week and abit. I'll post the relevant AS below:
//Play the first item when loading is complete
myList.addEventListener("CONTENT_LOAD_COMPLETE", this);
function CONTENT_LOAD_COMPLETE(evnt:Object) {
//Select first item in the list
myList.selectItemNum(0);
//Get and play the first item in the list
var item:Object = myList.getItemNum(0);
myPlayer.autoSize = false;
myPlayer.contentPath = item.data;
}
//Select next item when play completes
var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object):Void {
myList.selectNextItem();
//Get and play the next item
var item = myList.getSelectedItem();
myPlayer.autoSize = false;
myPlayer.contentPath = item.data;
};
myPlayer.addEventListener("complete", listenerObject);
//Play an item when it is clicked.
myList.addEventListener("ITEM_ON_RELEASE", this);
function ITEM_ON_RELEASE(evnt:Object) {
myPlayer.autoSize = false;
myPlayer.contentPath = evnt.target.data;
}
//this is the bit of code I added
//loading the XML and getting info for current track info
function loadXML(loaded) {
if (loaded) {
_root.content = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
_root.item = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
title_txt.text = _root.content;
desc_txt.text = _root.item;
}
else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("content2.xml");
Any more info needed let me know.
Mega thanks to anyone who can help!!
I then wanted to modify it to display the current track playing by using dynamic text.
I've got the info loaded into it fine but it only shows the information specified.
I think i need to make the "...this.firstChild.childNodes [0]..." variable so that when a new item is chosen from the media list the number "[0]" changes to the selected item number.
But that's where i get lost. I don't know if its possible or, if it is, how to do it.
I'm a real noob as they say, only had slash for like a week and abit. I'll post the relevant AS below:
//Play the first item when loading is complete
myList.addEventListener("CONTENT_LOAD_COMPLETE", this);
function CONTENT_LOAD_COMPLETE(evnt:Object) {
//Select first item in the list
myList.selectItemNum(0);
//Get and play the first item in the list
var item:Object = myList.getItemNum(0);
myPlayer.autoSize = false;
myPlayer.contentPath = item.data;
}
//Select next item when play completes
var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object):Void {
myList.selectNextItem();
//Get and play the next item
var item = myList.getSelectedItem();
myPlayer.autoSize = false;
myPlayer.contentPath = item.data;
};
myPlayer.addEventListener("complete", listenerObject);
//Play an item when it is clicked.
myList.addEventListener("ITEM_ON_RELEASE", this);
function ITEM_ON_RELEASE(evnt:Object) {
myPlayer.autoSize = false;
myPlayer.contentPath = evnt.target.data;
}
//this is the bit of code I added
//loading the XML and getting info for current track info
function loadXML(loaded) {
if (loaded) {
_root.content = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
_root.item = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
title_txt.text = _root.content;
desc_txt.text = _root.item;
}
else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("content2.xml");
Any more info needed let me know.
Mega thanks to anyone who can help!!