PDA

View Full Version : ActionScript, Flash, mxmlc, Flex Builder


stenrap
02-14-2009, 06:47 PM
Hi all,

I'm trying to wrap my brain around the relationships between ActionScript, the Flash authoring tool, mxmlc, and Flex Builder.

I began a project in the Flash authoring tool and quickly discovered that I'd prefer to control everything with ActionScript instead of the timeline (what can I say, I'm a software engineer by trade). This has mushroomed into a frame script with over 4,000 lines of code! Clearly I need reuseability and an object-oriented approach, so I will be developing classes in external .as files. However, having just finished reading Essential ActionScript 3.0 (the "Colin Moock book"), I'm still not sure how best to develop my project, include my .as files, and compile. As a result, I have a few questions:

1. When I create my classes, should I put them in a named package or the unnamed package? I'm leaning towards the unnamed package because apparently mxmlc and Flex Builder require them to be in the unnamed package, and just about every code example I've seen in Adobe's language reference shows classes in the unnamed package.

2. For my classes that represent displayable objects, should I extend MovieClip or Sprite? I think Sprite is the answer for external .as files, but only because that's what the Adobe examples show and the EA3 book recommends. I'm not sure why one or the other is better.

3. I can buy Flex Builder Pro for just $45 through my university's student discount. Is it worth it? Should I just use mxmlc for free, or am I really going to want Flex Builder Pro?

4. If I do buy Flex Builder Pro, is there any reason to use the Flash authoring tool ever again (why have both)?

5. Any other recommendations or best practices for me?

Thanks,
Rob

ASWC
02-14-2009, 07:12 PM
1. When I create my classes, should I put them in a named package or the unnamed package? I'm leaning towards the unnamed package because apparently mxmlc and Flex Builder require them to be in the unnamed package, and just about every code example I've seen in Adobe's language reference shows classes in the unnamed package.

It depends how your classes are reusable and how many you write. You might write only a few classes for a particular project so you'll likely never use them in another project so unnamed package is fine in this case but if you start to have a bunch of these kind of classes then packages would put some organization into it. Now for any classes you write that will be used on a regular basis for any project (utility classes and such) you really want to have them organized as much as possible so packages here sound good.

2. For my classes that represent displayable objects, should I extend MovieClip or Sprite? I think Sprite is the answer for external .as files, but only because that's what the Adobe examples show and the EA3 book recommends. I'm not sure why one or the other is better.

Sprite first if you can the reason being you can't create timeline based stuff with code (MovieClips have timeline, sprite don't). So extend MovieClip only if you need to control MovieClips which means only objects that were created with Flash software and have a timeline. If your object is created by code then it can't have a timeline so it needs only to be a sprite.

3. I can buy Flex Builder Pro for just $45 through my university's student discount. Is it worth it? Should I just use mxmlc for free, or am I really going to want Flex Builder Pro?

$45 is good go for it!

4. If I do buy Flex Builder Pro, is there any reason to use the Flash authoring tool ever again (why have both)?

With the Flash software you can create graphics with the authoring tools, create MovieClips with timeline animation and all that with only a few clicks while you can't do this with Flex at all.

5. Any other recommendations or best practices for me?

Think very hard when you create your classes on how you can make them as reusable as possible so after a while any project you'll start will be easier ans easier to complete!

stenrap
02-15-2009, 12:41 AM
Thanks for your reply--it was really helpful.

I reviewed the chapter on compiling, and I realized what I was missing regarding the unnamed package: Flex only requires the "main" application to be in the unnamed package (i.e. the "main" .as file that actually gets compiled). All other "supporting" classes can, and arguably should, reside in packages.

senocular
02-15-2009, 03:01 AM
Just to add to the topic, there's some general platform/tool comparisons here:
http://www.kirupa.com/forum/showthread.php?t=317573

I don't think mxmlc is called out to by name, but that's simply the compiler used by the Flex SDK. And of course (I think its assumed known in the thread listed above) ActionScript is simply the language used to handle logic in SWFs.