PDA

View Full Version : AS3 and Flash.



sceneshift
June 12th, 2007, 07:02 AM
Hey forums,

A lot of the online tutorials and documentation I have been reading assume that most AS3 projects are going to be created through the Flex IDE.

Since I am familiar with Flash, I was to develop my project from within Flash CS3 but keep with the popular class structure that is featured in most tutorials. Simply put, I was to code all my AS3 in separate .as files and important them into the .fla. Is this bad practise? I was hoping to keep my first frame in the timeline to something like:


stop();
import "as/movieAs.as"

Can anyway please tell me how this would be done in As3? I can figure out how to attach outside packages to movieclips via linkage, but not to the stage itself. (Also please bare in mind my .as files are in a "as" directory.

Cheers!

Dazzer
June 12th, 2007, 09:53 AM
You can still code on the timeline. However, the best way would be to have everything as separate files - use a documentClass.

pingnak
June 13th, 2007, 04:05 AM
I just spent the whole day building on the command line and coding in vi. Really.

Your use of import (it's not exactly like include) is what's buggered. I'm sleepy, but I'll spend a minute or two on it...

The statement should look like...
import my.lib.movie
or...
import movie

And that should make the compiler look for ./my/lib/movie.as or ./movie.as, with a class named 'movie' (and it is case sensitive), and cause it to get compiled, sort of like MXMLC will.

I tried to use the Flex IDE once... but the command line and FDB just worked better for me. I'll still have to decide whether Flash CS3 is more than the $600 friendlier when the free trial elapses. I'm probably stuck for it, as that interprocess communication to talk to AS2 code in AS2 art using AS3 is icky.

I instantly discovered that Flash will build a Flex project just like MXMLC does if you...

1. Make a new FLA file and save it in the same folder as the 'main' file you pass to mxmlc

2. Go to File->Publish Settings->Flash Tab->Settings... Button next to 'ActionScript Version', and tell it which class you'd have passed mxmlc on the command line in the 'Document Class' field. (In my case, that was Main.as)

3. Build it.

It absolutely will not work if the .FLA file is anywhere but in the root of your source code tree, in the same place as your 'Main.as'. If it blurts up some warnings when you press 'OK' in that 'Publish Settings' dialog, you screwed up. Check where you put the FLA file.

What I also discovered is there are a lot of handy classes and features in Flex that aren't defined in Flash. A non-trivial project could need some real 'refactoring'. Mine would have, except I have nothing but contempt for the 'IDE' provided by Flash.

You can also debug Flex apps in Flash CS3. It's under Debug->Begin Remote Session. Run a debug-built app with the debug player and Flash CS3 will debug it as if it's its own. You have to make a blank FLA file to make the debugger available for whatever reason. Once you've committed to that, you may as well make a 'Project' so you can keep track of those .as files conveniently.

sceneshift
June 13th, 2007, 05:49 AM
Thanks a lot for these replies, they were very helpful.