0 Replies Latest reply on Feb 14, 2007 8:00 AM by Whitetimer

    Reset TextArea Component

    Whitetimer Level 1
      Hi All ... Ok thi smay be a simple question, but being new, i'm still finding my way around Flex/Actionscript.

      OK...I have a component with a ComboBox and a TextArea. I make an HTTP call to an xml file which loads the "name" into the combo and the "description" into the textArea. I have a function that sets the selectedIndex=0 every time the page is shown. But how can i set the textArea back to the top of the text that is shown.

      <mx:Script>
      <![CDATA[

      import mx.rpc.events.ResultEvent;

      [Bindable]
      private var xmlWTFacts:XMLList;
      [Bindable]
      private var xmlWTC:XMLList;

      private function initXML(event:Event):void {
      wtFacts.send();
      wtCourses.send();
      }

      private function resetWhitetime(event:Event):void {
      vsWhitetime.selectedIndex = 0;
      }

      private function resetFacts(event:Event):void {
      cbWTFacts.selectedIndex = 0;
      }

      private function resetTraining(event:Event):void {
      cbWTCourses.selectedIndex = 0;

      }

      private function wtfRH(event:ResultEvent):void {
      xmlWTFacts=event.result.fact as XMLList;
      }

      private function wtCRH(event:ResultEvent):void {
      xmlWTC=event.result.level as XMLList;
      }

      ]]>
      </mx:Script>

      <mx:HTTPService id="wtFacts" url="./xml/wtfacts.xml" result="wtfRH(event)" resultFormat="e4x"/>
      <mx:HTTPService id="wtCourses" url="./xml/wtcourses.xml" result="wtCRH(event)" resultFormat="e4x"/>

      <mx:LinkBar id="lbWhitetime" x="10" y="5" height="30" dataProvider="vsWhitetime"/>

      <mx:ViewStack id="vsWhitetime" y="40" width="100%" height="100%">

      <mx:Canvas label="Facts About White Time" height="510" width="860" show="resetFacts(event)">

      <mx:HBox x="10" y="10" width="840" height="450" horizontalAlign="center" verticalAlign="middle">

      <mx:VBox width="300" height="430" horizontalAlign="center" verticalAlign="middle">

      <mx:Label width="250" styleName="myWTLbl" enabled="true" textAlign="center" text="A Short List Of Facts"/>
      <mx:Label width="250" styleName="myWTLbl" enabled="true" textAlign="center" text="About White Time"/>

      <mx:ComboBox id="cbWTFacts" width="250" styleName="myWTLbl" dataProvider="{xmlWTFacts}" labelField="number" />

      </mx:VBox>

      <mx:VBox width="500" height="430" horizontalAlign="center" verticalAlign="middle">

      <mx:Text width="300" height="200" styleName="myWTTxt" text="{cbWTFacts.selectedItem.description}" />

      </mx:VBox>

      </mx:HBox>

      </mx:Canvas>

      <mx:Canvas label="Training Course" height="510" width="860" show="resetTraining(event)">

      <mx:HBox x="10" y="10" width="840" height="450" horizontalAlign="center" verticalAlign="middle">

      <mx:VBox width="300" height="430" horizontalAlign="center" verticalAlign="middle">

      <mx:ComboBox id="cbWTCourses" width="250" styleName="myWTLbl" dataProvider="{xmlWTC}" labelField="name"/>

      <mx:Spacer height="200"/>

      <mx:Text width="200" styleName="myWTTxt" enabled="true" height="30" text="{cbWTCourses.selectedItem.cost}"/>
      <mx:Text width="200" styleName="myWTTxt" enabled="true" height="30" text="{cbWTCourses.selectedItem.duration}"/>

      </mx:VBox>

      <mx:VBox width="500" height="430" horizontalAlign="center" verticalAlign="middle">

      <mx:Label width="400" styleName="myWTLbl" enabled="true" text="{cbWTCourses.selectedItem.name}" height="30"/>

      <mx:TextArea id="ta1" width="400" styleName="myWTTxt" editable="false" wordWrap="true" enabled="true" height="125" text="{cbWTCourses.selectedItem.description}"/>
      <mx:TextArea id="ta2" width="400" styleName="myWTTxt" editable="false" wordWrap="true" enabled="true" height="250" text="{cbWTCourses.selectedItem.outline}"/>

      </mx:VBox>

      </mx:HBox>

      </mx:Canvas>

      </mx:ViewStack>

      </mx:Canvas>

      Many thanks for your help

      Shihan67