Flash vs. Flex: Why not skip Flex and use AS3's URLLoader + server code entirely?
I'm familiar with most of the Flash vs. Flex comparisons out there and most of them present some version of "Flex is better for RIA's while Flash is better for 开发者_运维技巧design work".
Yet isn't it entirely possible to write elaborate RIA's using the URLLoader class + server side code? In this regard, I'm unclear as to what Flex offers aside from a set of handy user controls.
The reason I ask is that I'm starting a fairly complex Flash piece that needs to take a lot of round-trips to the DB. I'm hoping to avoid introducing a new framework into the equation but don't want to get bit by performance, scaling issues down the road.
Thanks.
T
If all you need above basic Flash is to make HTTP requests to get data from the server, by all means, go ahead and use URLLoader.
Use Flex when:
- You do want that nice GUI library. (This can be as simple as a desire to use Flex's automatic layout facilities, like
VBox
es.) - You want to compile your app from the command line, like traditional software. (This is independent of the Flex framework. The Flex SDK build tools can also build plain old AS3 projects.)
- You want to build your application in a traditional software development IDE, Flex/Flash Builder, rather than the graphics and animation centric Flash Professional environment.
- Your UI is better declared in MXML than built graphically in Flash Professional.
Yes, I guess it would be possible to write RIAs using the URLLoader
class + server side code - but Flex makes it easier to write them.
[Bindable]
I believe one of the major features that makes RIA development easier with Flex is data binding.
For example, you can easily assign httpservice.lastResult
to the dataProvider of a DataGrid
and forget about it. In Flash, you need to manually parse each time complete
event is fired and recreate the dataProvider - while this might sometimes be efficient in terms of performance and memory management (provided we design it well), it takes some effort as compared to Flex's way of doing it with a one-liner.
Classes like XMLListCollection
and ArrayCollection
also makes things easier with flex.
Flash is meant for presentation/visual/pretty stuff. Flex is meant for data.
I beg to differ!
With the Flex SDK you can develop "pure" AS3 code that would do and look the exact same way that something you'd do with the Flash IDE. Flex is an AS3 framework made for developing RIA's but first of all it's an AS3 framework.
Lots of Flex developers were using Flash before Flex/FlexBuilder came out. I just think that if you're into "pure" development and don't need all of the Flash IDE's drawing tools, you'll feel much more confortable with a text editor and the flex sdk.
I use URLLoader in my flex code sometimes, and other times I use RemoteObject or HTTPService, I don't think there's any rule for that.
If you're going to be making a lot of round trips to the DB, I think it would be a good idea to consider Flex since you'll be able to use the faster and less verbose AMF protocol rather than HTTP/RESTful protocols, which are generally slow and 'heavyweight.'
Flex provides a pretty decent set of UI controls, which saves enormous time when dealing with large amounts of data. Have you ever built a control in Flash? It's tough to do right and bug free. So that's the #1 reason.
Also Flex, and especially Flash Builder 4, have features existing and upcoming that better interface with data sources of all types..
Flash is meant for presentation/visual/pretty stuff. Flex is meant for data.
精彩评论