Flexcoders Frequently Asked Questions Last Updated: 30th May 2005 ------------------------------------------------------------------------ Contributors:
Matt Chotin, Steven Webster, Alistair McLeod, Tariq Ahmed, Jeff Tapper, Peter Farland, Abdul Qabiz, Tracy Spratt, Jesse Warden, Dan Harfleet, Manish Jethani, Dimitrios Gianninas 1. What is Flexcoders? 2. How does Flexcoders relate to the Macromedia Flex Forum on www.macromedia.com? 3. Who posts to Flexcoders? 4. Resources to check before asking a question 5. Guidelines for effective question-asking 6. FAQ 1. What is Flexcoders? Flexcoders is a forum where developers can ask questions about Flex, FlexBuilder, and Flex-related technologies (like Cairngorm, FlexUnit and SynergyFLEX). The community is made up of everyday Flex developers as well as Macromedia employees. However, this is not an official Macromedia-sponsored forum, it is actually moderated by the folks at iteration::two, a consultancy responsible for authoring the book Developing Rich Internet Applications with Macromedia Flex. 2. How does Flexcoders relate to the Macromedia Flex Forum on www.macromedia.com? Both the Macromedia Flex Forum and Flexcoders provide help on issues related to Flex, and neither is an official support mechanism. Some people monitor both forums, some only one. It is up to you to decide where you might have a better experience getting a question answered and being able to subsequently help others. 3. Who posts to Flexcoders? Everyone who has a question or an answer. Many members of the Flex development team read and respond to Flexcoders as well as other Macromedia folks who monitor the community. Some recurring Macromedia folks are: David Mendels: EVP and GM, highest-level executive in charge of Flex. Lucian Beebe: Sr. Product Manager, Flex. Matt Chotin, Manish Jethani, Abdul Qabiz, Gordon Smith, Peter Farland and many more: Engineers on Flex. Active community members include: Steven Webster (Technical Director at iteration::two and co-author of Developing Rich Clients with Macromedia Flex), Alistair McLeod (Development Director at iteration::two and co-author of Developing Rich Clients with Macromedia Flex), Jesse Warden (JesterXL - Flash badass playing with Flex), Tracy Spratt (long-time member, holder of all knowledge related to 32K limits), Jeff Steiner (maintainer of www.flexauthority.com), Tariq Ahmed (maintainer of www.cflex.net), Jimmy Gianninas (long-time member, developer at Optimal Payments). And so many more! 4. Resources to check before asking a question The Flexcoders Mail Archive (better searching than YahooGroups): http://www.mail-archive.com/flexcoders%40yahoogroups.com http://www.cflex.net/showfaq.cfm http://livedocs.macromedia.com/flex/15/asdocs_en/index.html http://www.macromedia.com/go/flex15_java_livedocs http://www.macromedia.com/cfusion/knowledgebase/index.cfm http://www.cflex.net http://www.flexauthority.com http://www.macromedia.com/devnet/flex http://coenraets.com http://weblogs.macromedia.com/mxna/ http://www.google.com The Book "Developing Rich Clients with Macromedia Flex" (check your favorite bookstore) 5. Guidelines to effective question-asking Include a useful subject; this will help people find their own questions and answers later. Explain what you are trying to accomplish. Explain the error (include compilation errors or a description of the runtime behavior). Be prepared to break your problem down into a simpler scenario in case someone wants to try to debug the code themselves. Remember, private web services are inaccessible; you may need to create some dummy data to emulate problems. Phrases to avoid: "URGENT" (we all have deadlines, no one is intentionally delaying a response to you) "Please send code" (this is very frustrating to read as it implies you aren't interested in learning anything on your own. Where code is appropriate you can expect someone to provide it, but in many cases you will learn more by doing it on your own with appropriate guidance. It may be that you're on a deadline and just want to finish, but many of those who respond regularly would prefer to "teach you to fish" so that you can answer your own questions next time and even help out others). 6. Mini-FAQ Q: Can I mail Matt, Manish, Abdul, Pete, Gordon, iteration::two, or anyone else for that matter off-line with my question? A: Please don't! If someone is capable of answering your question on- list please believe that it will be done. Everyone on the list has full-time jobs doing their own work and often answer flexcoders on their own time; mailing them off- list doesnt endear you to them. If no one answers on-list in a reasonable amount of time (24 hours) you can try to rephrase the question and perhaps include more detail (including a version of the problem that someone can run without doing any setup on their own machine). ------------------------------------------------------------------------ Q: When is Flex 2.0 coming out, what will be in Flex 2.0? A: Macromedia has announced some preliminary details of Flex 2.0, codenames "Mistral" but not yet committed to any dates. There is some information on Mistral in the Flash Platform Whitepaper (page 21) http://www.macromedia.com/platform/whitepapers/platform_overview.pdf http://www.macromedia.com/go/platform ------------------------------------------------------------------------ Q: What does "Branch between ... and ... around line ... exceeds 32K span" mean and how do I get rid of it? A: Don't panic. Your app is NOT too big for Flex to handle. True, the 32k limit is a real Flash Player limitation to the size of certain structures like if blocks and for loops. But you don't really care about that right now, because you don't have any direct control over those things. Here is some information that will help you get back to coding: There are two main reasons you might the 32k issue. The primary cause, and the one to address first, is the architecture of your application code. The 32k error message asks you to "refactor" your code. Refactoring is essentially the process of modifying the structure of your source code while keeping the same functionality. In the Flex world, this means moving some parts of the code out of a main file and into separate components. One way to do this is to use custom mxml components. So instead of, say, having several hundred lines of mxml in a child container of a ViewStack, you put that mxml code into its own component file, and have a single line in the ViewStack to reference it. Do that for all the ViewStack children and 1000 lines of code can become 30. Decreasing the total number of visually rendered mxml tags in a single file will help avoid the 32k limit. Another type of refactoring is to move ActionScript code into its own class. Important note! Just putting the AS code into a file and then using the #include directive or the <mx:Script source="filename"> to include the code will NOT help with the 32k problem. You MUST create a true AS class that contains the functionality. Around two thousand lines of mixed mxml and AS code and you are in danger of the 32k error. I have not found an upper limit whatsoever to code length in a class. The second cause of the 32k error is not your fault. During compile, Flex generates AS code out of your mxml source. Then it compiles that into the Flash swf. In that process it makes decisions on how to break up your source and generate the AS class code. In Flex version 1.5, it doesn't always make the right decision, and the result is the 32k error. IF you are confident that you app is already efficiently "refactored", and you suspect you might be at one of these boundary conditions, first try compiling the app with ?debug="true" in the url. If the app compiles, then you are surely at a boundary condition. What is happening is that debug adds code to your source during generate/compile. This additional code causes Flex to change the structure of the AS classes so that the 32k limit is not hit. Hmm, more code? Yeah. Try just adding 50 or so lines of code, even if it is bogus. Usually, this will get you working. Now, when you add more real code go on and remove the bogus stuff, you don't want it in your production code! A final hint. After hitting a 32k error, and trying one of the above solutions, if you still get the error, delete the temporary generated as code. It is located in ..\MyAppServer\flex(flexroot or contextroot) \WEB- INF\flex\generated\*. You can delete all the folders safely (make sure to restart your Flex server). This can be an aggravating and somewhat scary problem, and it always seems to happen just before an important demo. Just use good, modular design, and remember the bogus code trick. Macromedia has stated a committment to improving this situation in the next release. ------------------------------------------------------------------------ Q: What does "Warning: Changes to unknown property, ..., will not be detected" mean and how do I get rid of it? A: Generally speaking, binding needs type information to set up its change detection functionality, and anything that hides this info can cause this problem. Don't use mx.core.application.application.myVariable in binding. If you are passing a reference to some component into another component via public properties, type the property variable definition as specifically as possible. When using "dot.down" notation to specify a property in an object or model, cast it to a type: text="{String(myObject.whatever.firstName)}" ------------------------------------------------------------------------ Q: Is there a Rich Text Editor? A: With the current Flex 1.5 component set, there is no Rich Text Editor unfortunately. There are some limitations in the current Flash Player that make such an editor difficult though there are implementations out there people have used. Macromedia has heard many requests for a Rich Text Editor and has indicated there might be better support in a future release. ------------------------------------------------------------------------ Q: How to run Flex as a Service? A: Flex is not a server that you deploy and run, it is simply deployed as part of your web application. So whatever web container you are using, either Tomcat, JRun 4, WebLogic, etc... so long as you can run any of those as services, then it will work. To learn how to deploy Tomcat, JRun 4 or any other Java server as a service, please refer to the appropriate documentation for the server you are using. ------------------------------------------------------------------------ Q: Does Flex work on my platform? A: Probably, search the archives if you have a specific question about your platform before posting to the list. ------------------------------------------------------------------------ Q: How do I get Flex to query my database? A: Flex does not have any native database integration functionality. you will require some server-side tier that will do the database access and send the data back to Flex via one of three protocols: * RemoteObjects: Fastest. communicates with server side EJB's or POJOs using AMF, a binary, compressed format. * HTTPService: uses HTTP protocol. Sources can be JSP, ASPx,.NET, files, any url that returns HTTP. * WebService: Slowest. Uses SOAP protocol. Sources can be .Net, or any WebService. ------------------------------------------------------------------------ Q: I'm sending my request, and I see the data traffic in the command window, but the result is always empty. A: You are probably trying to read the result immediately after the send(), right, expecting synchronous behavior? You can't do this. See "How do I make synchronous data calls?" ------------------------------------------------------------------------ Q: How do I make synchronous data calls? A: You CANNOT do synchronous calls. You MUST use the result event. No, you can't use a loop, or setInterval or even doLater. This paradigm is quite aggravating at first. Take a deep breath, surrender to the inevitable, resistance is futile. There is a generic way to handle the asynchronous nature of data service calls called ACT (Asynchronous Call Token). Search for this in Developing Flex Apps doc for a full description, but here it is in a nutshell. This example uses HTTPService but will be similar for RemoteObject and WebService: * First, create a function to handle the data return, like "onResult()" * In the HTTPService tag, put this function name in the "result" property, passing in event. <mx:HTTPService id="mxdsGetData" result="onResult(event)" ...> * Invoke the call in script: //invokes the call to the HTTP data service var oRequestCallbject = app.mxdsGetData.send(oRequest); //we will use this string value in the result handler. //Yes, you CAN set this AFTER you invoke send() oRequestCall.MyQueryId = "WhateverIWanttoUseToIdentifyThisCall" ; * In the result handler, which will be called every time the data service call returns, you identify what the returned data contains like this: var callResponse = oEvent.call; //get the call object //gets the value of this property you set in the call var sQueryId = callResponse.MyQueryId; //will be "WhateverIWanttoUseToIdentifyThisCall"; trace(sQueryId); You can use this sQueryId value in a switch to do the correct processing. Alternatively, you can pass reference to a handler function directly. ------------------------------------------------------------------------ Q: When I have only a single record, it does not display in my DataGrid A: This is a known issue that is caused by Flex's inability to differentiate between an object and an array with a single row. the solution is to ALWAYS use "toArray()". Here are some examples: In MXML: <mx:DataProvider> {mx.utils.ArrayUtil.toArray(modelAccidents1.accidents.accident)} </mx:DataProvider> And the inline format: dataProvider={mx.utils.ArrayUtil.toArray(testSrv.result.result.error)} And in ActionScript: myControl.dataProvider = mx.utils.ArrayUtil.toArray(testSrv.result.result.error) ------------------------------------------------------------------------ Q: I have two alerts in my code, but they are displaying in reverse! A: Actually, it is worse that that. Alerts, and "Modal" pop-up windows are not truly modal. They prevent user interaction with the interface, but they do NOT block code execution. What is happening is that both alerts are displaying, and the second one is on top of the first. The way to get the behavior you want is to use events and handlers. Your code must display the alert or modal pop-up, the end. When the user dismisses the prompt, you then complete the processing. You should be able to find some examples if this on one of the sites listed in "Resources" ------------------------------------------------------------------------ Q: The columns in my DataGrid are in some strange order! A: The order is typically the reverse of the order in which they were added. If you need a specific order, specify that and many other good things by using DataGridColumn tags. See the docs. ------------------------------------------------------------------------ Q: Can I embed HTML in my Flex application? A: Flex supports a limited subset of HTML in its TextArea and some other text- related classes. There is also a new article by Christophe on his blog discussing how to fake HTML with an IFRAME ( http://coenraets.com/viewarticle.jsp?articleId=95). ------------------------------------------------------------------------ Q: How can I make FlexBuilder faster? A: In order to improve FlexBuilder performance, it is best to disable the "Design View". This can only be done in FlexBuilder 1.5 and to do so, please follow these steps: * Select "Preferences" under the "Edit" menu * In the "General" section, remove the check mark next to Enable MXML Design View" * click on "OK" ------------------------------------------------------------------------ Q: Flex Builder debug does not stop at breakpoints in components A: The safest way to set breakpoints in component files is to use the Files list. Start the debugging session, nav you app to where you want to start debugging. Click the "Files" button on the Debug Toolbar, or go Menu Debug\Files. Select the component you want, usually the .mxml or .as files. The list strips out underscores in filenames, and can be very long, but this method always works. FB will open a temporary file, set the breakpoints, and away you go. ------------------------------------------------------------------------ Q: Are there frameworks available for Flex? A: Yep! Cairngorm: http://www.iterationtwo.com/open_source_cairngorm.html FlexUnit: http://www.iterationtwo.com/open_source_flexunit.html SynergyFLEX: http://www.mossyblog.com/archives/473.cfm (this link is for 1.0.0a) ------------------------------------------------------------------------ Q: When will Flex for .NET be available? A: Macromedia has not announced a date. // END ------------------------ Yahoo! Groups Sponsor --------------------~--> Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life. http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/nhFolB/TM --------------------------------------------------------------------~-> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/