View Full Version : Tree Component and Media Player
cealtman
11-28-2005, 03:13 PM
I am trying to use the tree component to have users play media clips in the Media Player component. I have found some tutorials on how to populate the Tree component. Is there any way to bind what is in the populated tree to the Media Player component? I would be great if I can accomplish this task with out having to use a List component in conjunction with this. I am having some difficulties with the list component as well when I use it with the tree. But that is for a another posting.
cancerinform
01-08-2006, 06:25 AM
1. Place a tree component on stage and name it myTree.
2. Place a mediaplayback component on stage and name it myAudio. In the property inspector set to mp3.
Now put this script in frame 1:
var myTree:mx.controls.Tree;
var myAudio:mx.controls.MediaPlayback;
myTree.setSize (200, 100);
var myTreeDP:XML = new XML ();
myTreeDP.ignoreWhite = true;
myTreeDP.load ("treeXML.xml");
myTreeDP.onLoad = function () {
myTree.dataProvider = this.firstChild;
};
var treeListener:Object = new Object ();
treeListener.change = function (evt:Object) {
myAudio.contentPath = evt.target.selectedNode.attributes.data;
myAudio.play ();
};
myTree.addEventListener ("change", treeListener);
and create this xml and name it treeXML.xml
<node>
<node label="Audio Folder">
<node label="track2" data="mp3/track2.mp3" isBranch="true" />
<node label="track3" data="mp3/track3.mp3" isBranch="true" />
<node label="track4" data="mp3/track4.mp3" isBranch="true" />
<node label="track6" data="mp3/track6.mp3" isBranch="true" />
</node>
</node>
Of course replace labels and path and names with your mp3 files. This is a basic way to combine the tree component with mediaplayback. :)
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.