0 Replies Latest reply on Dec 21, 2006 10:26 AM by nws_dave

    External XML

    nws_dave
      I'm looking for the proper way to do this exact demo, but instead load the XML from an external file, using HTTPService.

      Example:
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application
      xmlns:mx=" http://www.adobe.com/2006/mxml"
      viewSourceURL="src/XMLAssigning/index.html"
      width="500" height="470"
      creationComplete="myDataGrid.selectedIndex=0;"
      >

      <mx:Script>
      <![CDATA[
      // Model: XML structure describing
      // some of the books in my collection.
      [Bindable]

      private var myBooks:XML =
      <books>
      <book ISBN="1590595181">

      <title>Foundation ActionScript Animation: Making Things Move</title>
      <author>Keith Peters</author>
      <amazonUrl> http://tinyurl.com/npuxt</amazonUrl>

      </book>
      <book ISBN="1582346194">
      <title>Send in the Idiots: Stories from the Other Side of Autism</title>

      <author>Kamran Nazeer</author>
      <amazonUrl> http://tinyurl.com/lo5ts</amazonUrl>
      </book>

      </books>
      ]]>
      </mx:Script>

      <!-- Keep track of the currently selected book -->
      <mx:Number id="selectedBookIndex">{myDataGrid.selectedIndex}</mx:Number>


      <!-- User interface -->
      <mx:Panel
      title="Assigning XML data"
      paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10"
      >

      <!-- Master view: Display all books -->
      <mx:DataGrid id="myDataGrid" dataProvider="{myBooks.book}">

      <mx:columns>
      <mx:DataGridColumn dataField="@ISBN" headerText="ISBN" width="85"/>
      <mx:DataGridColumn dataField="title" headerText="Title"/>

      <mx:DataGridColumn dataField="author" headerText="Author"/>
      <mx:DataGridColumn dataField="amazonUrl" headerText="Web site">

      <mx:itemRenderer>
      <mx:Component>
      <mx:LinkButton
      label="Visit"
      click="navigateToURL(new URLRequest(data.amazonUrl), 'blank');"
      />
      </mx:Component>

      </mx:itemRenderer>
      </mx:DataGridColumn>
      </mx:columns>
      </mx:DataGrid>

      <!-- Detail view: Display currently selected book for editing -->

      <mx:Form width="100%" autoLayout="false">
      <mx:FormHeading label="Edit book details"/>

      <mx:FormItem label="ISBN:" width="100%">
      <mx:TextInput
      id="isbnInput"
      width="100%"
      text="{myBooks.book[selectedBookIndex].@ISBN}"
      change="{myBooks.book[selectedBookIndex].@ISBN = isbnInput.text}"
      />

      </mx:FormItem>
      <mx:FormItem label="Title:" width="
      100%">
      <mx:TextInput
      id="titleInput"
      width="100%"
      text="{myBooks.book[selectedBookIndex].title}"
      change="{myBooks.book[selectedBookIndex].title = titleInput.text}"
      />

      </mx:FormItem>
      <mx:FormItem label="Author:" width="100%">
      <mx:TextInput
      id="authorInput"
      width="100%"
      text="{myBooks.book[selectedBookIndex].author}"
      change="{myBooks.book[selectedBookIndex].author = authorInput.text}"
      />

      </mx:FormItem>
      <mx:FormItem label="Amazon Url" width="100%">
      <mx:TextInput
      id="amazonUrlInput"
      width="100%"
      text="{myBooks.book[selectedBookIndex].amazonUrl}"
      change="{myBooks.book[selectedBookIndex].amazonUrl = amazonUrlInput.text}"
      />

      </mx:FormItem>
      </mx:Form>
      </mx:Panel>
      </mx:Application>