One reason I like working at night is I can do a victory dance when I need to. And no, you are not doing the whole thing wrong!
With HTTPService, in addition to the "result" event, you have the 'fault" event. That will get called when the HTTPService call fails. Set up a handler function for it, just like for "result" (the event is a "FaultEvent", remember to import it). Of course, you will have to decide what you want to do in that case, but I can't help there. There is also the "try..catch..finally" block for error handling. Get your base functionality operating, then analyze error handling requirements. Tracy ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of shawn.gibson Sent: Tuesday, March 13, 2007 6:55 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: HTTPService-driven Tree This is funny. I just finished practically dancing around the room like a schoolgirl cuz I got this to work: public function treeChanged(event:Event):void { selectedNodeTree=Tree(event.target).selectedItem as XML; [EMAIL PROTECTED]; srv.send(); } But I KNEW I am doing this whole thing wrong. What happens if it can't find the file? What happens if, well, a lot of things can go wrong. I am going to back this up and start over, will print ALL of your info tomorrow and start with a blank slate as regards the data loading and handling. In fact, you made me realize something very important...do I ALWAYS want it to open the first gallery, the first node? On my home page, I want it to display say the 10 newest images, and you should be able to click that thumb and be brought into the gallery module with THAT as your initial galleryfile.xml AND that image AND the tree should be open there with the others closed....even if it's the nth image in the nth gallery resting in the nth node (of the nth node!) of the galleriesData file. I think most if not all of that rests in your responses so far. I have an incredible amount to learn...thanks for everything!!! I'll start over by studying your words in depth. Back this up, and begin anew... Shawn --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > Again you are close, and having the tile list get its data from > httpservice complicates things only slightly. > > > > First, Do not bind to lastResult. Ever. It is just too hard to debug, > and it is confusing, and it won't work for what you need to do. > Instead, use a result handler function. See my previous post for code > snippets. > > > > Do you want the tree to initially display with a particular node > selected? Which, the first? If so, do you want to display that nodes > thumbnails in the HL? If so, then in the handler, you need to set the > tree.selectedItem to the first node. > > myTree.selectedItem = _xmlData[0]; //You may need to call this with > callLater, depending on how/when you set the dataProvider > > > > Do you want the children of the first node expanded? It is probably > closed by default. Do this also in the handler. > > > > Create a function to invoke the send() on the thumbnail data call: > > private function getThumbnailData(sUrl:String):void { > > srv.url = sUrl; > > srv.send(); > ... > > > > When you initialize the tree, in the result handler function, call that > function to get the thumbnails for the first node: > > var sUrl:String = [EMAIL PROTECTED]; > > getThumbnailData(sUrl) > > > > Create a "change" event handler for the tree, and in it call the dat > send function for the thumbnails: > > private function onChangeTree(oEvent:Event):void { > > var xmlNode:XML = XML(oEvent.target.selectedItem); > > var sUrl:String = [EMAIL PROTECTED]; > > getThumbnailData(); > > > > Set up a result handler and instance variable for the thumbnail HL data > and away you go > > > > Tracy > > ________________________________ > > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of shawn.gibson > Sent: Tuesday, March 13, 2007 5:16 PM > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] Re: HTTPService-driven Tree > > > > This is actually, uh, slightly, more complex that I thought. > > The SHORT answer is, I get what you are saying I need to do: > initialize the first gallery to be loaded into the thumbnail/HL > thing, and use a tree change event method to pass to that providing > the proper gURL file in galleriesData.xml for the selected node. But > I can't change the data providor for the HorizontalList, because it > falls apart. > > In English: > > I have my galleries_module. It does this with the tree: > > <mx:Tree id="myTree" width="100%" height="90%" labelField="@label" > showRoot="false" dataProvider="{galXMLsrv.lastResult.root}" > change="treeChanged(event)"/> > > where it's 'fed' this: > > <mx:HTTPService id="galXMLsrv" url="model/galleriesData.xml" > useProxy="false" resultFormat="e4x" /> > > Here's what that file looks like: > http://shawngibson.com/faceitphoto.ca/shawn/model/galleriesData.xml <http://shawngibson.com/faceitphoto.ca/shawn/model/galleriesData.xml> > <http://shawngibson.com/faceitphoto.ca/shawn/model/galleriesData.xml <http://shawngibson.com/faceitphoto.ca/shawn/model/galleriesData.xml> > > > (view source, I don't know why it throws errors, it works fine) > > Part 2, that xml file, has gURL for each item node, meant to fire off > as I say my HorizontalList and load a new thumbnail file, let's say > Catherine.xml (it is in the /model directory)...but that HL is > comprised of the following: > > <mx:HorizontalList dataProvider="{srv.lastResult.gallery.piece}" > height="100%" width="100%" itemRenderer="Thumbnail" rowHeight="130" > columnWidth="175" backgroundAlpha="0.0" borderStyle="none"/> > > and is fed by: > > <mx:HTTPService id="srv" url="model/animals.xml" useProxy="false"/> > > Note the itemRenderer="Thumbnail" > > I use animals.xml as it's easy..."onLoad" it should grab the first > node item's gURL file as the file that loads initially into the > thumbscroller. Now that's the problem. What you want me to do, I lose > the binding on my HL, and the problem is that it's actually being fed > a component called Thumbnail, which I'll include here in it's > entirety: > > <?xml version="1.0"?> > <!-- dpcontrols/Thumbnail.mxml --> > <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > " > width="100%" height="100%" verticalAlign="middle" > verticalGap="0" > verticalScrollPolicy="off" horizontalAlign="center" > backgroundColor="#000000" backgroundAlpha="0.0"> > <mx:Image id="img" height="75" width="100" > source="{data.piclink}"/> > </mx:HBox> > > So, I'm lost. What it needs to do, based on what I can get from your > help so far is this: first, it needs to read the first XML gURL > value, and populate the HL/Thumbnail.mxml 'thinagamajig', i.e., in a > manner I'd say is '<BODY onLoad="somefunction();"' in html-speak - it > would load the first gURL in galleriesData.xml, first item node. > > From there, I think it needs to have a Tree change event, and do what > you said, provide the proper notification TO THE PROPER RECEIVER > (which isn't the HL, it seems) that 'hey, this is the new datasource > for the HL/Thumbnail thing, so please reload it to THAT Tree node's > gURL whatever.xml file. > > If this is clear as mud, I apologize. If the visual helps, my site is > here, and just navigate to galleries, then in the accordion, navigate > to the accordion header. It will make sense. > > I've set View Source to the whole thing if you are inclined to please > help get me started here. This knowledge will be applicable to most > of what I need to do to finish this site, and I would be greatly > appreciative. I've read thousands of pages since November, but I seem > to be needing some pretty non-standard stuff done. > > Here's my site in progress > > http://shawngibson.com/faceitphoto.ca/shawn/index.html <http://shawngibson.com/faceitphoto.ca/shawn/index.html> > <http://shawngibson.com/faceitphoto.ca/shawn/index.html <http://shawngibson.com/faceitphoto.ca/shawn/index.html> > > > I want this project to open source, free and available to anyone who > wants it. I've had it in my head for years, and I really hope someone > finds it valuable when I'm done. But I will need help because I'm > really a designer, and a photographer, so this heavy-duty coding, > while I find it extremely interesting and I'm passionate towards it, > it's just sometimes totally outside my ability to 'think like'. > > I've wanted to build an application for many many years...I'm at > least 1/3 of the way there, with this, I hope. At least for version > 1:) > > The reason I want everything XML-HTTPService driven, is that I'd like > to be able to give it to photographers who are not at all inclined to > be recompiling Flex Applications. Stage 2 will be to use the CF/Flex > wizard to populate the ACTUAL database (Access, MySQL, and hopefully > MS SQL if I can find $14,000 for the frigging licencing) and I > already have the CFC component to GENERATE the XML on the fly - > everything excluding the Tree, which requires coding for a Nested Set > or Adjacency model - I will most likely have to pay someone to build > that, the XML generator for the Tree (i.e., the galleriesData.xml > file), it's WAY out of my league. I have the database though, that > part is easy as pie, already works. In short, the photographer goes > in to the Admin section, gets the Flex/CF Wizard interface, does > his/her thing, then runs a CFC to regenerate the changed XML. This > frees up the server, it allows the photog to not have to be a coder, > and the only drawback is that the user must have a CF hosting service. > > I hope I've not ruined anyone's day with a bunch of useless reading:) > > Shawn > > --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders% 40yahoogroups.com> > , "Tracy Spratt" <tspratt@> wrote: > > > > "get the tree selected items to pass over into the horizontallist > item > > renderer-thingamajig" > > > > > > > > Two ways. Use a "change" handler on the tree and set the > > dataProvider=event.target.selectedItem. Or, bind to the > selectedItem: > > <myHorizontalList dataProvider="{myTree.selectedItem}" .../> > > > > > > > > Tracy > > > > > > > > ________________________________ > > > > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders% 40yahoogroups.com> > > [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders% 40yahoogroups.com> > ] On > > Behalf Of shawn.gibson > > Sent: Monday, March 12, 2007 8:13 PM > > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders% 40yahoogroups.com> > > Subject: [flexcoders] Re: HTTPService-driven Tree > > > > > > > > Woo hoo. I did it, thanks to you, Tracy. The only thing I didn't > for > > the life of me realize, is that you have to use the .send method > upon > > creation completion - so for all I know, all these times I've been > > trying, that was my biggest mistake. As I've been doing a lot of > > pasting from the examples, it never occured to me to go all the > way 'up > > there' LOL! > > > > I used exactly the kind of code you provided me...thank you! > > > > Now I just need to figure out how to get the tree selected items to > > pass over into the horizontallist item renderer- > thingamajig...live...so > > it changes the thumbs to the appropriate gallery when the user > selects > > the gallery via the tree. Then about a billion other things to > learn, > > then... > > > > :) > > > > Thanks for your help Tracy, it worked, the only missing piece was > my > > own ignorance... > > > > Shawn > > >