Hiya, I have a flex tree and every time it loads it only shows the one root folder, and i'd like it to show its full contents. I've seen loads of examples of people doing this, but just can't get it to work on mine. I think its because my tree is loading from an HTTPService, so whenever I try something it tries to do it before the tree has loaded, or something! Flex is doing my head in!
Can anyone show me where I should put extra code?
The xml that I'm getting from the http://localhost/upload/xml.php?userid=2 (incase you want to have a go recreating this) is:PHP Code:<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initVars()" height="400" width="150" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#D4F5FB, #D4F5FB]" themeColor="#FFFFFF" borderStyle="none" borderColor="#FFFFFF">
<mx:Script>
<![CDATA[
//treeXML.send();
[Bindable]
public var userid:String;
[Bindable]
public var userURL:String;
private function initVars():void {
userid = Application.application.parameters.userid;
showmeid.text = "$_SESSION['userid'] = " + userid;
userURL = "http://localhost/upload/xml.php?userid=" + userid;
showmeurl.text = userURL;
treeXML.send();
}
[Bindable]
private var textVis:Boolean = false;
private function switchVis():void{
if(textVis==true)
{
textVis=false;
}
else
{
textVis=true;
}
}
[Bindable]
[Embed("../assets/fclose.png")]
private var myFolderClosedIcon:Class;
[Bindable]
[Embed("../assets/fopen.png")]
private var myFolderOpenIcon:Class;
[Bindable]
[Embed("../assets/fclose.png")]
private var myDefaultLeafIcon:Class;
[Bindable]
public var selectedNode:XML;
// Event handler for the Tree control change event.
public function treeChanged(event:Event):void {
selectedNode=Tree(event.target).selectedItem as XML;
var url:String = selectedNode.@nodeURL;
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, '_self'); // second argument is target
} catch (e:Error) {
trace("Error occurred!");
}
}
]]>
</mx:Script>
<mx:HTTPService id="treeXML" url="{userURL}" resultFormat="e4x" />
<mx:Tree
horizontalScrollPolicy="on"
id="mytree"
dataProvider="{treeXML.lastResult.dir}"
labelField="@name"
change="treeChanged(event)"
top="0"
left="0"
right="0"
bottom="30"
borderStyle="none" backgroundColor="#D4F5FB"
defaultLeafIcon="{myDefaultLeafIcon}"
folderOpenIcon="{myFolderOpenIcon}"
folderClosedIcon="{myFolderClosedIcon}"/>
<mx:Button
y="372.5"
label="Refresh menu"
click="treeXML.send()"
horizontalCenter="0"
cornerRadius="0"
borderColor="#90A599"
fontWeight="normal"
fontFamily="Trebuchet MS"
fillAlphas="[1.0, 1.0, 1.0, 1.0]"
fillColors="[#F6F6EF, #F6F6EF, #F6F6EF, #F6F6EF]"
themeColor="#90A599"
fontSize="12" width="129" height="24.5"/>
<mx:HRule y="368" height="2" left="0" right="0"/>
<mx:TextArea x="10" y="213" width="130" id="showmeid" visible="{textVis}"/>
<mx:TextArea x="10" y="265" width="130" height="86" id="showmeurl" visible="{textVis}"/>
<mx:LinkButton click="switchVis()" x="73" y="333" label="Developer" textAlign="right" paddingRight="0" paddingBottom="0" paddingLeft="0" paddingTop="0"/>
<mx:TextArea x="10" y="10" width="130" height="195" id="showmeresult" visible="{textVis}"/>
</mx:Application>
Can annnnnnnyone help me pleeeeeaaaaaasssssse!!!PHP Code:<folders>
<dir name='Home' nodeURL='http://localhost/tidy/index.php?folder=1'>
<dir name='10' nodeURL='http://localhost/tidy/index.php?folder=23'>
<dir name='1010' nodeURL='http://localhost/tidy/index.php?folder=56'>
<dir name='Tralaaaa!' nodeURL='http://localhost/tidy/index.php?folder=58'>
</dir>
</dir>
</dir>
<dir name='David's folder' nodeURL='http://localhost/tidy/index.php?folder=22'>
</dir>
<dir name='fds' nodeURL='http://localhost/tidy/index.php?folder=21'>
</dir>
<dir name='Folder 1' nodeURL='http://localhost/tidy/index.php?folder=2'>
</dir>
<dir name='motor' nodeURL='http://localhost/tidy/index.php?folder=20'>
</dir>
</dir>
</folders>




Reply With Quote
