<p>Quite a few methods exist for passing data into a Flex binary from a Rails application.  Right now, I'm using the old e4x resultFormat with a xml.erb template.  I've done AMF before, but I feel like inlining parameters into the embed itself is a better solution because you don't have to wait for the browser to load a swf binary and the binary to make a web request.  </p>

<p>Taking all of that into account, what is the best practice for rendering a Flex widget with a Rails back-end these days?</p>

[{'answer_id': 47365, 'author': 'Theo', 'author_id': 1109, 'author_profile': 'https://Stackoverflow.com/users/1109', 'pm_score': 1, 'selected': False, 'text': '<p>Sounds to me like you shouldn\'t use Flex at all. Flex is great for writing applications that load and display data, but is a huge overhead if you just want to display charts. If you\'re worried about delivering the SWF and the data in two separate responses, you should be worrying about the 200-300 K overhead of the Flex framework.</p>\n\n<p>Go with something more lightweight like <a href="http://code.google.com/p/flot/" rel="nofollow noreferrer">Flot</a> and deliver the JavaScript code that generates the charts along with the data. I don\'t think Flex is a suitable platform for what you want.</p>\n'}, {'answer_id': 47369, 'author': 'Nick Retallack', 'author_id': 2653, 'author_profile': 'https://Stackoverflow.com/users/2653', 'pm_score': 1, 'selected': False, 'text': '<p>If the chart is just a graphic you are placing amidst normal html content, your solution of custom compiling the swf may be a good one.  Of course you should still explore alternatives like Theo\'s suggestion.</p>\n\n<p>If your whole application is flash, it\'s a toss-up.  If it is fastest to simply import a swf, go ahead.  However, if you need to make things any more interactive, use the data elsewhere, or fetch new data, it would probably be best to use xml templates as you are, or the <a href="http://www.railsbrain.com/api/rails-2.1.0/doc/index.html?a=M001377&amp;name=to_xml" rel="nofollow noreferrer">ActiveRecord::Base#to_xml</a> method if you\'re lazy.</p>\n'}, {'answer_id': 123866, 'author': 'defmeta', 'author_id': 10875, 'author_profile': 'https://Stackoverflow.com/users/10875', 'pm_score': 0, 'selected': False, 'text': '<p>It depends, are you going to want the charts to be \'live\', as in get updated in real-time when data changes? If so then using AMF with a Flex native RemoteObject gives you plenty of polling options, you can also just use a simpler Flex native HTTPService.</p>\n\n<p>Read about them both here: <a href="http://livedocs.adobe.com/flex/3/langref/index.html" rel="nofollow noreferrer">Flex Actionscript 3.0 Documentation</a></p>\n'}]
['https://Stackoverflow.com/questions/47297', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3499/']