0 Replies Latest reply on Oct 8, 2007 3:30 AM by joyfulrodger

    Need help trying to Navigate tree

    joyfulrodger
      Hi there,

      Im a flex novice and im not sure if this is the right place for this post but i couldnt find anywhere else so apologies in advance.

      Im trying to make a flex application which takes in information from an xml file, plugs it into a navigation tree then, when the appropriate node is selected displays some rich text in a central panel. I have this working but i would also like to be able to navigate through the parent nodes of the tree. This is where i am encountering a problem. I dont really know how to load in my xml in order to manipulate it like i want. Should it be in a XMLListm, a XMLListCollection or something else?

      I have two buttons at the bottom of my tree panel, one for previous and one for next and i want to be able to navigate through the slides. So if i am on one parent node i want to press next then go to the next parent node, open it and display the first child of it. If i am on a child node i want to press next and go to the next parent, open it and display the first child of it.

      I have spent ages trying to solve this problem and im really sorry if this is the wrong forum but im desperate. I've looked all over the web, used all my training resources and i just cant get it.

      Here is the code, at this point in time im just loading in an image and some text.

      Any help would be greatly appreciated,
      Thanks so much.


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="photosIn.send();">

      <mx:Script>
      <![CDATA[
      import mx.rpc.events.ResultEvent;
      import mx.collections.XMLListCollection;
      import mx.events.*;
      import mx.controls.Button;
      [Bindable]
      private var photos:XMLList;
      private var photoCollection:XMLListCollection;

      [Bindable]
      private var selectedXML:XML;

      private function photosXMLHandler(event:ResultEvent):void
      {
      photos = event.result..painting;
      }

      private function showImage(event:Event):void
      {
      var node:XML=event.target.selectedItem;
      {
      image.source = "assets/"+node.@desc+".jpg";
      text.text = node.@desc;


      }
      }

      private function previousChapter(event:Event):void
      {
      photoCollection = new XMLListCollection(photos.painting);
      var node:XML = XML(paintings.selectedItem);

      {
      photoCollection.length;
      i=i++
      }
      }

      private function nextChapter(event:Event):void
      {
      var node:XML = XML(paintings.selectedItem);
      {
      node = node;
      paintings.expandChildrenOf(node, true)
      image.source = "assets/"+node.@desc+".jpg";
      text.text = node.@desc;

      }
      }

      ]]>
      </mx:Script>

      <mx:HTTPService id="photosIn" url="assets/photos.xml" resultFormat="e4x" result="photosXMLHandler(event)"/>

      <mx:HBox id="display" label="display" height="95%" width="100%">
      <mx:Panel title="Paintings" height="95%">
      <mx:Tree change="showImage(event)" id="paintings" labelField="@desc" dataProvider="{photos}" height="95%"/>
      <mx:HBox width="100%">
      <mx:Button label="Previous" click="previousChapter(event)"/>
      <mx:Button label="Next" click="nextChapter(event)"/>
      </mx:HBox>
      </mx:Panel>
      <mx:Panel title="Painting" height="95%" width="50%">
      <mx:Image id="image" maintainAspectRatio="true"/>
      <mx:Text id="text"/>
      <mx:Button label="Launch IP"/>
      </mx:Panel>
      </mx:HBox>

      </mx:Application>