Hi Chris - I see nobody's responded to this yet, I would recommend you
try and simplify your post instead of putting in ALL of the MXML. Your
question is about using XML to populate a datagrid, so try reposting
your question with only the relevant MXML and Actionscript. I started
reading your post and then stopped when I saw all that code and thought,
I don't really have time to dig through it to assist. Anyway, that may
help you. Also, simplify your code a little and try this without the
catch/try routines. Also, where arey you declaring new XML() ?
Jason Merrill
Bank of America
GT&O L&LD Solutions Design & Development
eTools & Multimedia
Bank of America Flash Platform Developer Community
________________________________
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of CK
Sent: Thursday, January 17, 2008 3:04 PM
To: [email protected]
Subject: [flexcoders] Fwd: [Flashnewbie] XML Object by Reference
to DataGrid
Hi All,
On advice from the talented Jason Merrill, I throw my question
to
the think tank.
CK
Begin forwarded message:
> From: CK <[EMAIL PROTECTED] <mailto:ck%40bushidodeep.com> >
> Date: January 12, 2008 10:41:45 AM PST
> To: Flashnewbie Mailing List
<[EMAIL PROTECTED]
<mailto:flashnewbie%40chattyfig.figleaf.com> >
> Subject: [Flashnewbie] XMl Object by Reference to DataGrid
> Reply-To: Flashnewbie Mailing List
<[EMAIL PROTECTED]
<mailto:flashnewbie%40chattyfig.figleaf.com> >
>
>
> HI,
>
> This is an ambitious newbie FLEX application. The issue is my
> attempt creating an XML object by reference then populating
the
> DataGrid has failed. Will someone offer a solution?
>
> CK
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
> layout="absolute">
> <mx:Style>
> Label{fontFamily: Verdana; fontSize: 10pt; fontWeight: bold;}
> </mx:Style>
> <mx:Script>
>
> <![CDATA[
> import flash.events.Event;
> [Bindable]public var titleOverview:XML
> private function addOverview(e:Event):void
> {
>
> try
> {
> titleOverview=
> //Create the XML object using the values provided
> //by the users for the tag name, and contents.
> <dvd>
> <dvdTitle>
> {dvdTitle.text}
> </dvdTitle>
> </dvd>;
> }
> catch (e:TypeError)
> {
>
> titleOverview = <error>Fill In All Fields of the
> Overview.</error>;
> }
>
> }
> ]]>
> </mx:Script>
> <mx:Panel title="DVD Collection: Add Title" height="500"
> width="530" paddingTop="5" paddingLeft="5" paddingRight="5"
> paddingBottom="5">
> <mx:Accordion id="dvdAccordion" height="450" width="500"
x="10"
> y="31">
> <mx:Form id="dvdOverview" label="Overview" height="507"
width="635">
> <mx:Label text="Title:" width="48" height="19" />
> <mx:TextInput id="dvdTitle" width="290" height="25"/>
> <mx:Label text="Genre:" width="49" height="15" />
> <mx:ComboBox width="290">
> <mx:ArrayCollection>
> <mx:String>Action</mx:String>
> <mx:String>Sci-Fi</mx:String>
> <mx:String>Drama</mx:String>
> <mx:String>Foreign</mx:String>
> <mx:String>Comedy</mx:String>
> <mx:String>Horror</mx:String>
> <mx:String>Children's</mx:String>
> <mx:String>Romance</mx:String>
> </mx:ArrayCollection>
> </mx:ComboBox>
> <mx:Label text="Actors:" />
> <mx:TextArea id="dvdActors" width="450" />
> <mx:Label text="Director:" />
> <mx:TextInput id="dvdDirector" width="290" height="25"/>
> <mx:Label text="Producer(s):" />
> <mx:TextInput id="dvdProducers" width="290" height="25"/>
> <mx:Button label="Add DVD Overiew" id="addOverviewBtn"
> click="addOverview(event);"/>
> </mx:Form>
> <mx:Form id="dvdDetails" label="Details" height="508"
width="635">
> <mx:Label text="Plot:" />
> <mx:TextArea id="dvdPlot" width="450" />
> <mx:Label text="Review:" />
> <mx:TextArea id="dvdReview" width="450" />
> <mx:Label text="Rating:" />
> <mx:RadioButton groupName="dvdRating"
> id="dvdWatachable"
> label="Watachable"
> width="150"/>
> <mx:RadioButton groupName="dvdRating"
> id="dvdHorrible"
> label="Horrible"
> width="150"/>
> <mx:RadioButton groupName="dvdRating"
> id="dvdAwesome"
> label="Awesome"
> width="150"/>
> <mx:Label text="Date Purchased (MM/DD/YYYY):" />
> <mx:DateField id="dvdPurchaseDate" width="125" />
> <mx:Label text="Price (dollars . cents) :" />
> <mx:HBox width="200">
> <mx:Text text="$"/><mx:TextInput width="50" height="20"/
> ><mx:Text text="."/><mx:TextInput width="50" height="20"/>
> </mx:HBox>
> <mx:Label text="Date Released (MM/DD/YYYY):" />
> <mx:DateField id="dvdReleaseDate" width="125" />
> <mx:Label text="Length (HH MM SS) :" width="265"/>
>
> <mx:HBox width="200">
> <mx:TextInput width="50" height="20"/><mx:Text text=":"/
> ><mx:TextInput width="50" height="20"/><mx:Text text=":"/
> ><mx:TextInput width="50" height="20"/>
> </mx:HBox>
> <mx:Button label="Add DVD Details" id="addDetailsBtn" />
> </mx:Form>
>
> </mx:Accordion>
> </mx:Panel>
> <mx:Panel title="DVD Collection: View Titles" height="300"
> width="59%" paddingTop="5" paddingLeft="5" paddingRight="5"
> paddingBottom="5" x="0" y="518">
> <mx:DataGrid width="100%" editable="true"
> variableRowHeight="true" x="538" height="250"
> dataProvider="{titleOverview.dvd}">
> <mx:columns>
> <mx:DataGridColumn dataField="title" headerText="Title"
> editable="false" />
> <mx:DataGridColumn dataField="genre" headerText="Genre"
> editable="false" />
> <mx:DataGridColumn dataField="actors" headerText="Actors"
> editable="true" />
> <mx:DataGridColumn dataField="directors" headerText="Director"
> editable="false" />
> <mx:DataGridColumn dataField="producers" headerText="Producer"
> editable="true" />
> </mx:columns>
>
> </mx:DataGrid>
> </mx:Panel>
> <mx:Panel x="538" y="0" width="450" height="500"
layout="absolute"
> title="DVD Collection: Detailed View">
> </mx:Panel>
> </mx:Application>
>
> _______________________________________________
> [EMAIL PROTECTED]
<mailto:Flashnewbie%40chattyfig.figleaf.com>
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashnewbie
<http://chattyfig.figleaf.com/mailman/listinfo/flashnewbie>
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com <http://www.figleaf.com>
> http://training.figleaf.com <http://training.figleaf.com>