views:

146

answers:

5

Since Flex generates Actionscript. Why not use Actionscript at all ?!

sorry, i'm just curious .

+3  A: 

I think a rhetorical question best answers this:

Why not use raw machine code for all projects?

In more detail, the Flex Framework is indeed written in pure actionscript. It offers substantially more than actionscript alone, and like most frameworks, addresses a need for higher level programming constructs that are not offered by the language that they are written in.

spender
+4  A: 

Flex does not generate ActionScript. Flex compiles ActionScript.

At any rate, Flex is Flash programming aimed at developers (who don't necessarily like having timline-based vector editor as the main development environment).

Also, since Flex is a console application, you can include its functionality in shell scripts etc etc.

Matt
do you have any example for the console application ?!
mr.bio
technically, the flex tools create actionscript code when parsing MXML.
jedierikb
+1  A: 

Adobe Flex and Adobe Flash differs in only one thing:

According to Adobe: "Adobe Flash is for designers, Adobe Flex is for developers. Flex is released for developers who do not feel comfortable with timeline stuff. "

Adobe Flash is a powerful tool; however, as more programmers became involved in building Rich Internet Applications, it quickly became clear that they were not comfortable using drawing tools, timeline and other visual panels to create forms and other elements that are common to the business application.

Adobe Flex was created to solve this problem for programmers.

See this video: http://www.adobe.com/devnet/flex/videotraining/xml/vid01.html

If you feel comfortable with timelines (i am not) then there is no difference at all. You can use Adobe Flash.

JCasso
Every Flex project I've worked on has incorporated both designers and developers. I feel comfortable with timelines and the majority of my work is done with Flex inside of Flash Builder.
Joel Hooks
One obvious difference between Flex and Flash is that you get code completion in Flex. BTW- If you feel like any of us have answered your question please mark it 'answered' by clicking on the check-mark next to the post (to the left).
jml
@jml, I think you are not comparing Flex and Flash here, but Flex Builder and Flash Professional (CS3/CS4), i.e. the tools, while the original question seems to be about the platforms. Of course, code completion has nothing to do with the framework you use, but the IDE.
richardolsson
+4  A: 

I agree with the points made about Flex being for developers and Flash being for designers, but that doesn't really cover what is going on in detail.

There are three main ways to produce a Flash application (SWF): 1) Using the Flash application - the timeline approach, mainly aimed at designers.

2) Writing pure ActionScript directly and compiling (either through an IDE such as FlashBuilder or from the command line), aimed at programmers with creative flare or designers who don't mind getting their hands dirty.

3) Writing 'Flex' - usually using an IDE such as FlashBuilder, but yes you can compile your Flex application on the command line. Flex is MXML (an XML markup) and ActionScript. As stated, Flex is aimed at software developers, typically those who have less focus on the 'creative' side (delegating this responsibility elsewhere, e.g. a visual designer).

There's a big difference between #2 and #3 though.

ActionScript is great for programmers who want to do highly interactive and graphical Flash application, for instance, some interactive demo or a game perhaps. To create a Flash app via ActionScript you would create an ActionScript file, add the meta data to indicate it is an application and the compiler will generate an appropriate and usually very small SWF file. There are some components available at the pure ActionScript level, but these are very lightweight compared to Flex and most of the work is done by manipulating Sprite objects.

Flex does a lot more. It gives the developer a rich suite of skinnable components with which to build applications, a component lifecycle, effects and data bindings to name a few things. I would say that Flex is more for rich applications for some business domain, typically in the format of a form based application, though you can do some very sexy things with it and can pull in resources created elsewhere (e.g. existing Flash resources).

A Flex application has a top level 'Application' object which is an MXML file containing a hierarchy of components. At compile/build time this MXML file is converted to ActionScript (lots of it! there is a compiler flag which keeps the generated ActionScript, see the docs for more info) which is ultimately compiled in to a SWF that can run in Flash Player.

For instance, you would add Labels, TextInputs, Buttons and so on to a Panel and add the Panel to the application. The user interacts with these components, and then the Flash app processes the input in some way and updates the view. Data binding allows you to mark an object as 'bindable' and then have Flex automatically update some other property when the bindable property changes.

Flex applications tend to generate larger SWFs, but that is because they are carrying the 'baggage' of the Flex SDK, though this can be mitigated using runtime shared libraries (a bit like DLLs for Flash, but is an advanced topic) or Modules, which are SWFs that will only run inside of a Flex application and not standalone. But the idea is that the application is loaded in to the client and is responsive without having to perform page-requests as in a traditional web application. The perception of loading time is improved by breaking your application up in to modules or using runtime shared libraries as mentioned above.

To be honest, I'm not doing Flex justice with my description, but hopefully I have made the differences much clearer.

brindy
+1  A: 

The Flex framework allows developers to write applications more rapidly than writing pure ActionScript. Flex is written in MXML, which is a 'convenience language' and has a lot of pre-built components for writing business applications.

However if your goal is for creative purposes only, Flash would be a better tool for the job. But if you're asking between AS3 and Flex, I presume you're not tweening things in a timeline, as you would in Flash.

If you start using Flex, you will find that you must know ActionScript to give your app functionality that's not provided out of the box. Also, knowing ActionScript will be beneficial to both Flex and Flash worlds (and you can also write pure AS3 apps as well, but very few folks do that in my experience).

lelander