[flexcoders] Dynamically updating the contents of a ViewStack
Hello, I'm building a Flex application that looks like this (warning, pseudo code): Application VBox ApplicationControlBar ToggleButtonBar dataProvider=x/ /ApplicationControlBar ViewStack id=x v:Products v:Login /ViewStack /Application After a user logs in, I'd like the v:Login to become v:Profile. How can I make this happen? PS, I'm also using Cairngorm. Thanks, Ian
[flexcoders] XML to AS3 object
Hello, I'm getting XML from an HTTPService call (and/or a WebService call, I don't think this matters). I want to take this XML and put it into my AS3 objects (ValueObjects using Cairngorm terminology). I'm currently using Darron Schall's ObjectTranslator, which is great but doesn't work for rich object graphs. Are there any tools for making this XML-AS3 object translation easier? I have a bunch of Java Beans and an XSD that describe my types. Maybe there's a tool to generate AS3 objects from an XSD (and generate the code necessary to translate XML into the object). If there's nothing out there, I think I'll try and take Darron Schall's ObjectTranslator and make it work for more general cases... Although I'm pretty new to AS3 so I'm not sure how far I would get. Ian
[flexcoders] HTML to Flash (Flex) application migration
Hello, I've been tasked with a project to migrate an HTML online store (very basic, add stuff to the cart, manage your profile, checkout) to Flash. I plan to use Flex to make this happen. My experience with Flex is minimal. I am an experienced Java developer. My big question is: How will I interact with the backend database? The current application is separated nicely into MVC components (and I have full control over the backend, so I can tweak/add whatever is necessary). I've used the HTTPService object to retrieve XML over HTTP. This method works, but it doesn't seem very scalable (as far as developer productivity goes) since I have to expose a new method in my web application for each desired call. So I'm thinking that taking advantage of either Web Services or FDS would be a good idea. Unfortuantely, I don't have any experience in either of these... I'm sure there are other concerns I'm not even thinking of right now. What are these? One other concern, the load on this store can be *very* high. This is for a world famous rock band and they sell a very small number of tickets to their shows online. The demand for these tickets can be very high, so whatever is implemented must be scalable. I'm open to any suggestions, comments, or questions. Thanks, Ian
Re: [flexcoders] Printing a DataGrid using a PrintDataGrid
Thanks for the code, but I'm not sure if this solves the problem. I went to the Flex2 demo (http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html) and tried the printing demo. If one prints 3 or more pages, one can see that the data grid on the second page could have more rows. (This problem is highlighted when the heading on the first page is large.) In other words, the height of the data grid is not changing according to the space available on the page. With my limited knowledge of Flex2, it seems that the PrintDataGrid should have a method fitToPage or something like that which will resize it according to the space left on the page. Ian Igor Costa wrote: Here's a short example of PrintJob copied from Components Explorer. // The function to print the output. public function doPrint():void { var printJob:FlexPrintJob = new FlexPrintJob(); if (printJob.start()) { // Create a FormPrintView control as a child of the current view. var thePrintView:FormPrintView = new FormPrintView(); Application.application.addChild (thePrintView); //Set the print view properties. thePrintView.width=printJob.pageWidth; thePrintView.height=printJob.pageHeight; thePrintView.prodTotal = prodTotal; // Set the data provider of the FormPrintView component's data grid // to be the data provider of the displayed data grid. thePrintView.myDataGrid.dataProvider = myDataGrid.dataProvider; // Create a single-page image. thePrintView.showPage(single); // If the print image's data grid can hold all the provider's rows, // add the page to the print job. if(!thePrintView.myDataGrid.validNextPage) { printJob.addObject(thePrintView); } // Otherwise, the job requires multiple pages. else { // Create the first page and add it to the print job. thePrintView.showPage(first); printJob.addObject (thePrintView); thePrintView.pageNumber++; // Loop through the following code until all pages are queued. while(true) { // Move the next page of data to the top of the print grid. thePrintView.myDataGrid.nextPage(); thePrintView.showPage(last); // If the page holds the remaining data, or if the last page // was completely filled by the last grid data, queue it for printing. // Test if there is data for another PrintDataGrid page. if(!thePrintView.myDataGrid.validNextPage) { // This is the last page; queue it and exit the print loop. printJob.addObject(thePrintView); break; } else // This is not the last page. Queue a middle page. { thePrintView.showPage (middle); printJob.addObject(thePrintView); thePrintView.pageNumber++; } } } // All pages are queued; remove the FormPrintView control to free memory. Application.application.removeChild(thePrintView); } // Send the job to the printer. printJob.send(); } Best On 2/14/07, *Ian Shafer* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hello, I'm using PrintDataGrid to print a DataGrid and everything is working fine except one thing. The size (height) of the PrintDataGrid same one every page. This would be okay if I were just printing the PrintDataGrid, but I have a header on the first page (and footers on subsequent pages). The example code for this (in the Developing Flex Applications guide) is great and I followed it to a tee (I think). My current solution is to manually set the height of the PrintDataGrid after the first page. This is a lame solution because I'm doing something like this: printView.reportsTable.height = printJob.pageHeight - 20; (If I set the height to printJob.pageHeight I get a scrollbar and my footer (with page number) doesn't show.) Any idea what's causing this? Here's the pertinent code snippets: ** Application View ** private function printTable():void { var
[flexcoders] Printing a DataGrid using a PrintDataGrid
Hello, I'm using PrintDataGrid to print a DataGrid and everything is working fine except one thing. The size (height) of the PrintDataGrid same one every page. This would be okay if I were just printing the PrintDataGrid, but I have a header on the first page (and footers on subsequent pages). The example code for this (in the Developing Flex Applications guide) is great and I followed it to a tee (I think). My current solution is to manually set the height of the PrintDataGrid after the first page. This is a lame solution because I'm doing something like this: printView.reportsTable.height = printJob.pageHeight - 20; (If I set the height to printJob.pageHeight I get a scrollbar and my footer (with page number) doesn't show.) Any idea what's causing this? Here's the pertinent code snippets: ** Application View ** private function printTable():void { var printJob:FlexPrintJob = new FlexPrintJob(); if (!printJob.start()) { return; } var printView:CategoryOrderReportTablePrintView = new CategoryOrderReportTablePrintView(); var pageNumber:int = 1; addChild(printView); printView.width = printJob.pageWidth; printView.height = printJob.pageHeight; printView.reports = _reports; printView.pageNumber = pageNumber; printView.totals = this.calcTotals(this._reports); printView.description = this.formatDate(_options.startDate) + - + this.formatDate(_options.endDate); printJob.addObject(printView); while (printView.reportsTable.validNextPage) { pageNumber++; printView.reportsTable.nextPage(); printView.reportsTable.height = printJob.pageHeight - 20; printView.pageNumber = pageNumber; printJob.addObject(printView) } printJob.send(); removeChild(printView); } ** Print View ** public function set pageNumber(pageNumber:int):void { footer.pageNumber = pageNumber; if (pageNumber == 1) { header.includeInLayout = true; header.visible = true; footer.includeInLayout = false; footer.visible = false; } else { header.includeInLayout = false; header.visible = false; footer.includeInLayout = true; footer.visible = true; } validateNow(); }
[flexcoders] Handling initialized event with AS3 custom component
Hello, How do I handle an initialized event using an AS3 custom component? In MXML it would be like this: mx:VBox initialize=myHandler mx:Script![CDATA[ private function myHandler():void { // Do something } ]]/mx:Script /mx:VBox My guess is that I can do something like this: package com.example.test { public class Test extends VBox { private function initialize():void { // Do something } } } But I can't find any documentation. Thanks, Ian
RE: [flexcoders] Re: Flex 2 HTTPService best practices
Thank you all for the great help. I can't tell you how much I appreciate it. One note. I mentioned the command line debugger in my initial post. I got this working in linux (Ubuntu 6.10). I had to manually install the flashplayer executable from the Adobe website (I couldn't find it in the SDK) and I also linked gflashplayer to flashplayer so the debugger (fdb) would work. Ian On Wed, 2007-01-31 at 17:45 -0500, Tracy Spratt wrote: I have never been comfortable with the “black box” conversion from xml to mx:Object. I went with xml in 1.5 and am delighted with e4x. I read the post above on XMLEncode with interest and plan to look at that, but since I hav so far been in control of both ends, the data type problems has not been an issue. You should know about AsyncToken and the ACT pattern. It lets you match up results to the corresponding data call, so you can decide how to porcess the result. You can even define a handler function, which I think is known as “closure”. More info is availble on all this. Tracy __ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Chris Luebcke Sent: Wednesday, January 31, 2007 3:48 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Flex 2 HTTPService best practices So I tried setting the resultFormat to object for a service that returns a fairly deep XML structure. I found that it did a pretty good job of mapping the text nodes to the correct types (Boolean, String and Number); it didn't map 2006-11-17 to a Date, but hey, you can't be all things to all people. Anybody else out there have experience with resultFormat=object? Is there any documentation that specifically describes how the object graph is put together and what the text-node-to-object rules are? I suppose I could go look at the source code, but figured I might as well ask around first. Thanks, Chris --- In flexcoders@yahoogroups.com, Chris Luebcke [EMAIL PROTECTED] wrote: Hi Ian, I'm using XML over HTTPService in my current app and may be able to help with some of this. Responses inline below. --- In flexcoders@yahoogroups.com, Ian Shafer ian@ wrote: ...regarding using HTTPService: * Should I be using it? I'm choosing to use HTTPService because I don't want to pay for FDS and it (HTTPService) *seems* simple so that if there are problems, I could easily be able to fix them (as opposed to using FDS and Adobe's proprietary encoding). Also, XML over HTTP is simple and always works. Hooking up remote objects just seems like a pain. The answer to that question ultimately comes down to your specific project needs, of course. I'm not using FDS (for the usual reasons), and there doesn't appear to be an open-source (or otherwise really cheap) alternative to using AMF3 to communicate to a Java backend. So that really leaves some flavor of XML over HTTP as the raw message language and protocol. We deliberated between SOAP, REST and homegrown XML message protocols, and ultimately settled on homegrown for a variety of reasons I won't bore you with. Again, it really depends on your specific needs, but so far our solution is shaping up very nicely. * What is the best resultFormat to use. As far as I can tell, there are three: object, e4x, and xml. The xml format seems obsolete since we now have e4x. Is there any reason to use xml? I get e4x (pretty sweet, I think this is a *great* language feature). The only drawback I've found so far is the datatype of e4x values. They all seem to be Strings. I get this, but I wonder if there's an easy way to say all @quantity fields are numeric so it'll sort nice in a DataGrid. object seems cool, but I'm not 100% clear how it works. Me neither, frankly. I might consider trying it, though, given that there is apparently some basic type casting done when you use this format, according to the dev guide: By default, the resultFormat property value of HTTPService components and WebService component operations is object, and the data that is returned is represented as a simple tree of ActionScript objects. Flex interprets the XML data that a web service or HTTP service returns to appropriately represent base types, such as String, Number, Boolean, and Date. To work with strongly typed objects, you must populate those objects using the object tree that Flex creates. Can I tell HTTPService which class to bind the objects to? I don't use Flex Builder (again, I don't like to pay for software, and I don't have the money), so it's tough to introspect the objects at runtime (although I did see something about command line debugging, I'll have to look into that). I believe this creates a new graph of objects with dynamically created properties. I don't
[flexcoders] HTTPService request parameters - multiple values for the same name
Hello, I'm not 100% sure this is compliant with the HTTP spec (I know the Java servlet libraries handle it, so I'm guessing it is to spec), but I want to pass multiple values for the same name. Example: http://test.com/doit.cgi?country=UScountry=AU This doesn't seem to be possible using an Object to hold the request parameters in HTTPService. I currently have a work-around in place (http://test.com/doit.cgi?countries=US,AU), but I like the first way better. Thanks for any insight, Ian
[flexcoders] Flex 2 HTTPService best practices
Hello, I'm pretty new to Flex and Flash (about two weeks in). I'm an experienced Java developer, so I do have a solid background. I have a number of questions regarding using HTTPService: * Should I be using it? I'm choosing to use HTTPService because I don't want to pay for FDS and it (HTTPService) *seems* simple so that if there are problems, I could easily be able to fix them (as opposed to using FDS and Adobe's proprietary encoding). Also, XML over HTTP is simple and always works. Hooking up remote objects just seems like a pain. * What is the best resultFormat to use. As far as I can tell, there are three: object, e4x, and xml. The xml format seems obsolete since we now have e4x. Is there any reason to use xml? I get e4x (pretty sweet, I think this is a *great* language feature). The only drawback I've found so far is the datatype of e4x values. They all seem to be Strings. I get this, but I wonder if there's an easy way to say all @quantity fields are numeric so it'll sort nice in a DataGrid. object seems cool, but I'm not 100% clear how it works. Can I tell HTTPService which class to bind the objects to? I don't use Flex Builder (again, I don't like to pay for software, and I don't have the money), so it's tough to introspect the objects at runtime (although I did see something about command line debugging, I'll have to look into that). * I want to call (HTTPService.send()) my service with different query parameters. What's the best way to do this? Currently, I'm creating a new HTTPService in AS and generating the URL every time it is called. This doesn't seem right to me. * Should I use a service-config.xml file? I haven't been able to find good documentation on this? I think that about does it. Thanks for any help! Ian