Disadvantages of a Flex project vs an Actionscript

2019-03-28 13:53发布

问题:

I've recently started making a game in FlexBuilder. The game is currently a Flex project.

Is there any downside to using Flex as opposed to just Actionscript?

A friend of a friend told me that Flex is slower than an Actionscript project. I've been unable to validate this on the internet; is there any truth to that claim?

Thanks!

回答1:

  • If you're developing a game, you should be using an ActionScript project. Flex is to be used only for data driven applications and user interfaces.
  • The flex compiler generates a lot of intermediate code to convert mxml files into actionscript (you can view those files if you compile with -keep compiler option). This code, the flex framework incorporated to your SWF, adds significantly to the size.
  • Create an actionscript project with a textfield ("hello world") and a flex project with a label with the same text. Build them, go to their bin-debug folders and compare the file sizes. While actionscript one is only a couple of kilobytes, flex swf would be at least a 100 kB.
  • As far as speed is concerned, since the flex framework is sitting on top of actionscript, it obviously would have a performance downside.
  • The beauty of flex lies in the easiness to create UI components and developing data driven applications that frequently communicates with the server.
  • Don't use it unless you truly need it.


回答2:

If you know flex and it helps you developing faster - do it in flex.

Download size doesn't matter for game with a lot of assets. Most popular flash games have size of 5 MB and more. (for example on kongregate)

Crucial part of game you can make in pure actionscript. Placing hundreds UIComponents to Canvas could doesn't slow in Flex, but Flex rending technology prevent smooth animation of objects.

Conclusion: Flex is for rapid development. You can use it's easy skinnable components for menu. Even without Flex UI components binding is matter and makes life easier.



回答3:

Download size = speed on the Internet. The smaller you can make your game, the faster it will load. Size also equals speed in an interpreted language like ActionScript, where the less code you have to execute, the faster it will run. Hand-coding an ActionScript routine might let you make it faster than the generalist approach of Flex.

That said, maybe you'd be willing to pay that overhead to avoid having to write a lot of utility classes in pure ActionScript. Your high-score screen would be easier to do in Flex, for example, and that might be worth the overhead to you. It won't matter if your high-score screen is a little slower, since it isn't a real-time thing like the actual game.

Also consider the cost of your time. By using Flex, you'll be done with those parts of your app faster than if you hand-code them in ActionScript. Unless your time is free, you should be thinking about how this trades off against the bandwidth cost of the Flex overhead. It might be that it's cheaper to pay the bandwidth than your time making a more efficient program.



回答4:

A Flex Application won't necessarily run slower than a Pure AS3 application once it's fully loaded - everything gets compiled down to bytecode in the end, and a Flex App is like an AS3 app that uses a LOT of other classes.

Think of the Flex Framework as a set of shortcuts that allow you to do things much more quickly, but the real cost is that your project gets filled up with a LOT more code - even if you're actually writing less code, and you never have to see the additional code.

I would disagree with the assertion that Flex should only ever be used for complex data-driven applications, though it's certainly very useful for such projects. You can use it for anything, as long as you understand that the final product (the .swf you export) is going to be a lot larger than it might otherwise be.

If having a large .swf is not that big a deal to you (and it might not be, depending on what you're doing with it) then I'd say give Flex a try because ArrayCollection, RemoteObject and Data-Binding will save you hours of frustration and hundreds of lines of code.

However, if you want to make sure your final app is as small and efficient as possible, do it in pure AS3 and simply opt-in to more advanced libraries as you need them.



回答5:

Flex provides a framework for building Rich Internet Applications. If your game requires a complicated GUI (such as an RPG), it might be useful. Otherwise, it adds layers that will complicate things if all you want to do is build a game.



回答6:

As said above in the first point the only beverage is memory consume. But if u write in pure AS script you need to be in deadline combat. As flex provide lots of customizable comps. U can use Class files instead of MX Comps that save the Memory. Do not Create any components unless it is being used. Modules and RSLs are avail to acheive the peretainity