Flexcoders Frequently Asked Questions
Last Updated: 17th September 2008
------------------------------------------------------------------------
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, Amy Blankenship
1. What is Flexcoders?
2. How does Flexcoders relate to the Adobe Flex Forum on
www.adobe.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 and FlexUnit).
The community is made up of everyday Flex developers as
well as Adobe employees. However, this is not an official
Adobe-sponsored forum, it is moderated by the community.
2. How does Flexcoders relate to the Adobe Flex Forum on
www.adobe.com?
Both the Adobe 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
Adobe folks who monitor the community.
Some recurring Adobe folks are:
Matt Chotin, Product Manager Flex.
Alex Harui, Gordon Smith, Peter Farland, Seth Hodgson, Jeff Vroom and many more: Engineers on Flex and BlazeDS/LCDS.
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.adobe.com/cfusion/webforums/forum/index.cfm?forumid=60
http://www.adobe.com/cfusion/knowledgebase/index.cfm
http://www.cflex.net/showfaq.cfm
http://www.cflex.net
http://www.adobe.com/devnet/flex
http://feeds.adobe.com
http://www.google.com
Flex 1.5 specific
http://livedocs.macromedia.com/flex/15/asdocs_en/index.html
http://www.adobe.com/go/flex15_java_livedocs
The Book "Developing Rich Clients with Macromedia Flex" (check your
favorite bookstore)
Flex 2.0 specific
http://livedocs.macromedia.com/flex/2/
http://www.onflex.org/code/
Flex 3 specific
http://livedocs.adobe.com/flex/3/
Check out the open source wiki for the Flex SDK at http://opensource.adobe.com/flex
More resources can be found at http://www.flex.org as well.
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 folks 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 doesn't 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 the next version of Flex coming out, what will be in that version?
A: The Flex team will list any public info at http://blogs.adobe.com/flex, or check the Open Source Flex SDK site at http://opensource.adobe.com/flex
------------------------------------------------------------------------
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 callLater. 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.
------------------------------------------------------------------------
Q: When I have only a single record, it does not display in my DataGrid
A: Set resultFormat="array".
------------------------------------------------------------------------
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: Are there frameworks available for Flex?
A: Yep! Cairngorm, PureMVC, Mate, Prana, FlexUnit, Fluint, and many more.
------------------------------------------------------------------------
Amy's Flex Frequently Asked Questions (courtesy of Amy's Flex Diary:
http://flexdiary.blogspot.com/)
Q: I want to use an XML data source to dynamically display images and
data in my Flex application. I won't know how many images/data points I
will have at design time. How can I best approach this?
A: Depending on what you're wanting to do, you can either use a
Repeater with an Image or custom component that contains an Image or you
can use a List based component to display an Image or custom component
with an Image (or SwfLoader, or Loader) in it. The Help is full of
resources on this subject. Here are some places you may want to try:
Help>Flex Start Page>Creating a Simple RIA
Help>Help Contents>User Interfaces
- Using Data Providers and Collections
- Controls
- Image
- SwfLoader
- Using Data Driven Controls
- Using Item Renderers and Item Editors
- Dynamically Repeating Controls and Containers
Here is an example that might get you running fast if you find it easier
to learn from a working example than from Help files:
http://examples.adobe.com/flex2/inproduct/sdk/photoviewer/PhotoViewer.
html
Q: I've created a custom itemRenderer component to use in a List
based component (Datagrid, TileList, HorizontalList, etc.). When my
List first displays, everything looks fine, but when I scroll it or
change the dataProvider, some of the itemRenderers show values or
formatting that aren't right. How do I fix this?
A: List-based components don't draw a renderer for every item in the
dataProvider. Instead, they create enough to display what is on screen
now, plus one or two more waiting in the wings. This means they
recycle the renderers rather than creating new ones when you change
dataProvider or scroll up and down. When you use a creationComplete
event to set up the itemRenderer, that event doesn't happen again when
the renderer is used for a different set of data. The solution to this
is to override the set data protected function that most components
have.
For more information, check out the following resources:
http://www.adobe.com/devnet/flex/articles/itemrenderers_pt1.html?devcon=
f1
http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.
html
Q: I want to run a function in my main application from inside my
custom component. But when I try to refer to myFunction() in that
component, I get a compile time error "Call to a possibly undefined
function myFunction." How can I fix this?
A: Your component has its own scope, so it doesn't know anything
about the functions in the main file. You can get around this by
directly referencing the main application scope like this:
Application.application.myFunction(). However, this makes your
component tightly coupled, which is a quick way of saying that your
component is only usable in an application that has a myFunction()
function in it. You're better off dispatching an event from your
component and letting the application decide how to handle it. For more
information, check out the following resources:
http://www.adobe.com/devnet/flex/articles/loose_coupling.html
http://www.adobe.com/devnet/flex/articles/graduating_pt1.html
Q: I want to decide at runtime what kind of component to add to
display my data. How can I accomplish this?
A: Use getDefinitionByName and ClassFactory to dynamically create
your class. Just be sure that you actually have at least one "hard"
reference to each class you intend to use, or the class might not get
compiled into your swf. Here's a full write-up of how to do that:
http://www.paulofierro.com/archives/520/
Q: I need to set a property or add an event listener on a component
that is in a ViewStack/TabNavigator/Accordion. When the component is
not the first child of the Navigator Container, I get a null object
error (#1009). What causes this, and how can I fix it?
A: By default, the Navigator containers only create the children of
each pane as that pane is viewed. The easy way to fix this is to set
the creationPolicy on the Navigator to "all." However, this will cause
your application to take longer to load. A better way to fix this is to
wait for a later event, such as creationComplete on the component you
want to access, or to use binding to "pull" the data into the component.
The way I handle it is to call invalidateProperties() on change of the
ViewStack. I then override commitProperties() and call an "initializer"
for each pane. In the body of each initializer function, I check to see
if the selectedItem for the viewStack is the one my initalizer cares
about. If not, I return from the function immediately. Inside that
initializer function, I set properties and add listeners as appropriate.
Q: When my application is taller than the browser window, I get
scrollbars in the application. I want the browser to do the scrolling.
How can I do this?
A: In the html-template/index.template.html file change line 46 (in
the Flex 3 template) to read <body scroll="auto"> instead of the default
of <body scroll="no">.
Q: I am using URLRequest, HTTPRequest, or HTTPService to retrieve
information from a database on a server. The first time my application
makes a server call, it works fine. But when I call the same page
again, I get the same data, even though I know the data has changed on
the server. Is this a bug?
A: The browser has cached the response it got from the first call you
made to the page. This means that you need to either change how you are
calling the page so it appears to be a new request, or you need to
change the page itself so that it won't be cached.
To change how you are calling the page, append a unique value to the end
of the URL. For example, new URLRequest('yourPage.asp?param="+(new
Date()).getTime).
If you want to change the page itself, you need to change the response
headers. The method for changing the response headers will vary from
language to language. For more on this see:
http://msdn.microsoft.com/en-us/library/aa923184.aspx
http://www.sun.com/books/components/Hall_ch7.pdf
http://www.w3schools.com/php/func_http_header.asp
http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_g-h_07.html#3989067
Q: I am using Modules in my Application. When I load the first Module, everything works fine. But when I load the second one, I get a Type Coercion Error failed error #1034 that looks something like TypeError: Error #1034: Type Coercion failed: cannot convert com.myDomain.package::SingletonClass@fce9a89 to com.myDomain.package::SingletonClass or TypeError: Error #1034: Type Coercion failed: cannot convert mx.managers::HistoryManagerImpl@22346589 to mx.managers.IHistoryManager. How do I fix this?
A: When you reference a singleton class, either a custom singleton or one of the managers in Flex, into a Module, if this is not loaded in the Application domain, it will load into the child domain of the first Module to load and other Modules will not be able to see it. To prevent this, either directly load your class into the main Application before loading any Module, or use a Runtime Shared Library with the class included.
For more on this, see Alex Harui's presentation on Modules from Flex 360 http://blogs.adobe.com/aharui/2007/03/modules.html (slides 19, 24-31).
Not sure what a Singleton is? Check out http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&postId=262&productId=2
Q: I'm using a Repeater to lay out the right number of components on the screen for me based on a data source. I'm trying to set up the id for each component dynamically like this:
<mx:Repeater id="myRepeater" dataProvider="mySource">
<mx:Button id="{'myButton'+myRepeater.currentIndex}" label="{myRepeater.currentItem.label}" />
</mx:Repeater>
When I try to run the file, I get a compiler error '{'myButton'+myRepeater.currentIndex}' is not a valid identifier.
I need to be able to reference each of the repeated components. How can I do this?
A: If you give the component an ordinary id like this:
<mx:Button id="myButton" label="{myRepeater.currentItem.label}" />
Flex will create an Array for you called myButton that contains a reference to each component the repeater created. For more information, see Referencing Created Components here:
http://livedocs.adobe.com/flex/3/html/help.html?content=repeater_3.html
// END
0 comments:
Post a Comment