0 Replies Latest reply on Mar 25, 2010 8:10 AM by home_aidan

    Hows my code look?

    home_aidan

      Hi,

      Ive spent some time coding in flex/flash builder before, but havent touched it for a year.

       

      So now im just dusting off the skills.

       

      Ive downloaded a trial of flash builder4 and I set my self the task of populating a tree component and using it as a navigation tool, by changing states.

       

      Everything works exactly as I want it, I just want to see what you guys think of it and if you would do anyother way.

       

      Thanks

       

      [CODE]

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

         xmlns:s="library://ns.adobe.com/flex/spark"

         xmlns:mx="library://ns.adobe.com/flex/mx"

         minWidth="955" minHeight="600">

      <s:states>

      <s:State name="exampleState1"/>

      <s:State name="exampleState2"/>

      </s:states>

      <fx:Script>

      <![CDATA[

      import mx.events.ListEvent;

      private function itemClick(evt:ListEvent):void{

      var dataObj:Object = evt.itemRenderer.data;

      if (dataObj.hasOwnProperty("@newstate")) {

      var newstate:String = dataObj.@newstate;

      trace("newstate   "+newstate);

      currentState=newstate

      }

      }

       

      ]]>

      </fx:Script>

       

      <fx:Declarations>

      <fx:XML id="dp">

      <root>

      <folder label="Folder for state 1">

      <item label="gotoState1" newstate="exampleState1" />

      </folder>

      <folder label="Folder for state 2">

      <item label="gotoState2" newstate="exampleState2"  />

      </folder>

      </root>

      </fx:XML>

      </fx:Declarations>

       

      <mx:Tree id="tree" dataProvider="{dp}"

      showRoot="false"

      labelField="@label"

      rowCount="6"

      itemClick="itemClick(event);" x="10" y="4" height="364" width="274"/>

      <s:TextArea includeIn="exampleState2" x="290" y="4" text="THIS IS STATE2"/>

      <s:TextArea x="290" y="4" text="THIS IS STATE1" includeIn="exampleState1"/>

       

      </s:Application>

       

      [/CODE]