| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
how do u display a list of whats in your XML ??
Ok i've made an mp3 player in flash . it uses an XML menu to provide the songs , what i would like help with is making a list to display all of the songs , if there is a tutorial or if anyone can help me i would highly appreciate it
__________________
You have just qualified for self defense. |
|
#2
|
|||
|
|||
|
first of all....you can use a lot of things to display the list...you can use a table(dataGrid component), a html formated text field, a list (list component - you can customize this) or you can just use the Tree component...
this is the simplest way...just adda tree instance in a movie,give it a instance name like "myTree", then add this code to the frame on which the component is : Code:
var myTreeDP:XML = new XML();
myTreeDP.ignoreWhite = true;
myTreeDP.load("treeXML.xml");
myTreeDP.onLoad = function() {
myTree.dataProvider = this.firstChild;
};
Code:
var treeListener:Object = new Object();
treeListener.change = function(evt:Object) {
trace("selected node is: "+evt.target.selectedNode);
trace("");
};
myTree.addEventListener("change", treeListener);
you can easily change the trace action in something else to get the desired effect... add a list component to the stage, instance name "myList" then add this code to the same frame on witch the List component is Code:
myDP = new Array();
var songs:XML = new XML();
songs.ignoreWhite = true;
songs.onLoad = function(success) {
i = 1;
for (var aNode = songs.firstChild; aNode != null; aNode=aNode.nextSibling) {
myDP.addItem({label:i+"."+aNode.attributes.song+" "+aNode.attributes.duration, data:aNode.attributes.src});
i++;
}
_root.myList.dataProvider = myDP;
};
songs.load("treeXML.xml");
}
for making use of the selectedItem property of the list component, you would use this code attached to a button : Code:
on(release){
trace(_root.myList.selectedItem());
trace("");
this is exactly the same as for the list component, just that you will not be able to use it interactive...so just a simple list...text... - make a dynamic text field on the root, instance name "myHTMLt", make sure you select the render as HTML option. - add this code to the same frame on whitch the dynamic text box is : Code:
myDP = new Array();
var songs:XML = new XML();
songs.ignoreWhite = true;
songs.onLoad = function(success) {
i = 1;
for (var aNode = songs.firstChild; aNode != null; aNode=aNode.nextSibling) {
myHTMLt +=i+"."+aNode.attributes.song+" "+aNode.attributes.duration + "
";
i++;
}
_root.myList.dataProvider = myDP;
};
songs.load("treeXML.xml");
}
I think i've covered enough so you can make your choice.... after you decide on what method you whant to use, please let me know...I can help you and explain things in more detail...I have a lot of spare time right now also, I think this will help...just to make a ideea http://flashaddict.uv.ro/player/player_final.html I made this some time ago.... |
|
#3
|
|||
|
|||
|
WOOO
Thank you , and yes i would like help (is your actionscript designed for flash 8 ??) because im at school right now in class (HIGH SCHOOL 12th grade YAHHHH!!!! anyway 8) and the school has Flash Mx 2004. The list works , except it does not display my music list it displays undefined, twice , on one line ,like this: 1. undefined undefined there is no line 2 this is on the same layer as the list Code:
myDP = new Array();
var songs:XML = new XML();
songs.ignoreWhite = true;
songs.onLoad = function(success) {
i = 1;
for (var aNode = songs.firstChild; aNode != null; aNode=aNode.nextSibling) {
myDP.addItem({label:i+"."+aNode.attributes.song+" "+aNode.attributes.duration, data:aNode.attributes.src});
i++;
}
_root.myList.dataProvider = myDP;
};
songs.load("playlist.xml");
and i have another layer for the button and i put the code on the button Code:
on (release) {
trace(_root.myList.selectedItem());
trace("");
}
sooo....yah i have no clue I really appriciate all this help man thank you |
|
#4
|
|||
|
|||
|
please give me the structure of the xml file cuz probably that's why it doesen't work....those examples are made for my own xml files, so the structure may differ...
the undefined things tell me that you have something like this in you'r xml : Code:
<node type="head">
<node type="album">
<node type="song" tytle="Nirvana - Molly's Lips" src="c:\folder\file1.mp3">
<node type="song" tytle="Nirvana - About A Girl" src="c:\folder\file2.mp3">
</node>
</node>
and my code is making this : trace "1." trace first node's tytle attribute (it has no tytle attribute) trace second node's tytle attrubute (it has no such attribute then it stops... so I need the XML's structure... I see that you whant to use the list component....I will tell you how to customize that so it look's exactly like you whant it to look (just some simple stuff) |
|
#5
|
|||
|
|||
|
cheers to graduating! I'm in the same boat and thank god for that!
|
|
#6
|
|||
|
|||
|
Here is my XmL format
Code:
<?xml version="1.0" encoding="iso-8859-1"?> <songs> <song name="Freak on a leash rammstein remix" file="H:\MP3_player\Rammstein\Korn & ramstien - Freak on a leash rammstein remix.mp3"/> <song name="Letting Go" file="H:\MP3_player\illnino\11 Letting Go Ill Nino Confession.mp3" /> </songs> basicly...yah after this WE officially HAVE NO LIFE. |
|
#7
|
|||
|
|||
|
Sergiu_spooky:
THANK UUUUUUUUUUUUUUUUUUUUUUU 8) 8) 8) |
|
#8
|
|||
|
|||
|
first of all, delete this from your xml : <?xml version="1.0" encoding="iso-8859-1"?>
then, replace the code that loads your xml and places it in the list with this : Code:
myDP = new Array();
var songs:XML = new XML();
songs.ignoreWhite = true;
songs.onLoad = function(success) {
i = 1;
for (var aNode = songs.firstChild.firstChild; aNode != null; aNode=aNode.nextSibling) {
myDP.addItem({label:i+"."+aNode.attributes.name, data:aNode.attributes.file});
i++;
}
_root.myList.dataProvider = myDP;
};
songs.load("playlist.xml");
this should perfectly load your playlist... next...that button... the code should be : Code:
on (release) {
if (_root.myList.selectedItem<>undefined) {
trace(_root.myList.selectedItem.data);
}
}
next, customizing the list... The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". Specifies colors for rows in an alternating pattern. The value can be an array of two or more colors, for example, 0xFF00FF, 0xCC6699, and 0x996699. Unlike single-value color styles, alternatingRowColors does not accept color names; the values must be numeric color codes. By default, this style is not set and backgroundColor is used in its place for all rows. The background color of the list. The default color is white and is defined on the class style declaration. This style is ignored if alternatingRowColors is specified. The background color when the component’s enabled property is set to "false". The default value is 0xDDDDDD (medium gray). The List component uses a RectBorder instance as its border and responds to the styles defined on that class. See RectBorder class. The default border style is "inset". The text color. The color for text when the component is disabled. The default color is 0x848384 (dark gray). A Boolean value that indicates whether the font specified in fontFamily is an embedded font. This style must be set to true if fontFamily refers to an embedded font. Otherwise, the embedded font will not be used. If this style is set to true and fontFamily does not refer to an embedded font, no text will be displayed. The default value is false. The font name for text. The default value is "_sans". The point size for the font. The default value is 10. The font style: either "normal" or "italic". The default value is "normal". The font weight: either "none" or "bold". The default value is "none". All components can also accept the value "normal" in place of "none" during a setStyle() call, but subsequent calls to getStyle() will return "none". The text alignment: either "left", "right", or "center". The default value is "left". The text decoration: either "none" or "underline". The default value is "none". A number indicating the text indent. The default value is 0. The name of the default icon to display on each row. The default value is undefined, which means no icon is displayed. The number of milliseconds of delay between when a user first presses a button in the scrollbar and when the action begins to repeat. The default value is 500, half a second. The number of milliseconds between automatic clicks when a user holds the mouse button down on a button in the scrollbar. The default value is 35. The background color of a rolled-over row. The default value is 0xE3FFD6 (bright green) with the Halo theme and 0xAAAAAA (light gray) with the Sample theme. When themeColor is changed through a setStyle() call, the framework sets rollOverColor to a value related to the themeColor chosen. The background color of a selected row. The default value is a 0xCDFFC1 (light green) with the Halo theme and 0xEEEEEE (very light gray) with the Sample theme. When themeColor is changed through a setStyle() call, the framework sets selectionColor to a value related to the themeColor chosen. The length of the transition from a normal to selected state or back from selected to normal, in milliseconds. The default value is 200. The background color of a selected row. The default value is a 0xDDDDDD (medium gray). Because the default value for this property is the same as the default for backgroundDisabledColor, the selection is not visible when the component is disabled unless one of these style properties is changed. The color of text when the mouse pointer rolls over it. The default value is 0x2B333C (dark gray). This style is important when you set rollOverColor, because the two settings must complement each other so that text is easily viewable during a rollover. The color of text in the selected row. The default value is 0x005F33 (dark gray). This style is important when you set selectionColor, because the two settings must complement each other so that text is easily viewable while selected. Determines whether rolling over a row activates highlighting. The default value is true. (from flash MX 2004 7.2 help) all these properties can be used like this : place this code on a frame(preferably in the same place you placed the code that loads the playlist) : Code:
myList.setStyle("themeColor","haloOrange");
myList.setStyle("useRollOver",false);
myList.setStyle("textRollOverColor",0xFF0000);
|
|
#9
|
|||
|
|||
|
YES!!!!!!!!!!
Danke thank u woooooooo it wooorks ok . calming down........ thanks soo much thank u thank u |
|
#10
|
|||
|
|||
|
no problem...glad to help
|
|
#11
|
|||
|
|||
|
ok ,my
teacher is asking me to see if i could get the list to work like thiswhen you click a song name within the list the mp3 player will jump to it , like in windows media player if you could help i would appreciate it oh and another thing why did i have to delete <?xml version="1.0" encoding="iso-8859-1"?> from my XML ? Thank You |
|
#12
|
|||
|
|||
|
you have to delete that because it's not important for flash(not for what you are making) and because it's one more node that needs to be taken account of in the actionscripting...
you could leave it there...no problem... as for the play thing, use this code : Code:
var my_sound:Sound = new Sound();
myDP = new Array();
var songs:XML = new XML();
songs.ignoreWhite = true;
songs.onLoad = function(success) {
i = 1;
for (var aNode = songs.firstChild.firstChild; aNode != null; aNode=aNode.nextSibling) {
myDP.addItem({label:i+"."+aNode.attributes.name, data:aNode.attributes.file});
i++;
}
_root.myList.dataProvider = myDP;
};
songs.load("tree.xml");
var listenerObject:Object = new Object();
listenerObject.change = function(eventObject:Object) {
my_sound.loadSound(myList.selectedItem.data, true);
my_sound.start();
};
myList.addEventListener("change", listenerObject);
stop();
the load part is the same, just add this : Code:
var my_sound:Sound = new Sound();
var listenerObject:Object = new Object();
listenerObject.change = function(eventObject:Object) {
my_sound.loadSound(myList.selectedItem.data, true);
my_sound.start();
};
myList.addEventListener("change", listenerObject);
this will play the song when you click it (make sure you have correct paths in the xml) |
|
#13
|
|||
|
|||
|
I THANK YOU
you are a genius My teacher says thanks as well. !!!!!!!! |
|
#14
|
|||
|