Getting More Out Of FAME


The following article gives some suggestions for utilizing your FAME environment to it's fullest. Specifically, the following topics are covered:
Tracing Debug Output
Setting Up A Class Library
Working With Art Resources

By the way, the topics are not dependent on each other, and you can work through them in any order.

Before delving into this article, you should have installed Eclipse and MTASC, and successfully created a couple of test projects. If you need help getting started, see my previous tutorial.

Tracing Debug Output

Note: This section assumes that you are using v. 0.2 or higher of Flashout.
Flashout has built-in Trace functionality that is on par with the Flash Authoring Environment. If you're used to working with the Flash Authoring Environment, you'll have to get used to a new syntax.

If you followed the directions I provided for setting up Eclipse in my previous tutorial, you should be able to find a file in the root of your Eclipse directory.

This file is required for tracing output. If you leave this file right where it is, you should be able to use the Flashout class without an import statement. Alternatively, you could move into your MTASC/src directory, or even your [project]/src directory. (I don't recommend the later because then you'll have to make a new copy of every time you set up a new project.)

IMPORTANT: If you're using version 1.10 or higher of MTASC, you'll need to modify the file because the MTASC TRACE command has been changed to trace. Just open and do a global search & replace to fix this inconsistency.

Here's a simple class you can use to confirm that Flashout tracing is working correctly:

class Test{
   function Test(scope:MovieClip) {
   Flashout.serverIn("this is a Server In message");
   Flashout.serverOut("this is an Server Out message");
   Flashout.log("this is a Log message");
   Flashout.debug("this is a Debug message");"this is an Info message");
   Flashout.warning("this is a Warning message");
   Flashout.fatal("this is a Fatal message");
   Flashout.error("this is an Error message");

//Main Entry Point
 static function main() {
   var test:Test = new Test(_root);

Compile the class and, provided you didn't get any errors, you should see a blank SWFPreview window in Flashout. Click the tab on the bottom that says "Logger". You will see all 8 of the debug messages come up in order of increasing priority.

Try playing around with the "Log Filter" dropdown, and observe that you can restrict which messages are displayed. You'll see that "debug" and "log" are actually the same thing. I'm not sure why both are supported -- perhaps just for convenience. Make note of the other "Logger params". In particular, "Pause" can be extremely useful for debugging looping SWFs that output new info every frame. There's even a handy search field at the bottom to help you look through your log.

Setting Up A Class Library

Before you get too far along with FAME, you'll probably want to set up a folder for common classes that you will use in multiple projects. There are a couple of ways to add a new path for MTASC, but I think the easiest is to supply a "-cp" parameter to MTASC through Flashout. To do this, open your flashout document, select the "Compilation status/preferencese" tab, and then add "-cp" followed by the path to your library.

(Note that you can also pass parameters to MTASC through the Preferences dialog, or you can supply a classpath for a particular project. Unfortunately, I haven't had much luck with these methods, so I would recommend just passing in all your parameters to MTASC via Flashout.)

You might also want to create a seperate project in Eclipse for your class library, so you have easy access to your files. In fact, I would highly recommend doing so because Eclipse seems to fail when you try to open a .as file that's not attached to a Project! Select File/New/ActionScript2 Project. Give your Project a name, and, before moving on, uncheck the box under "Project Contents" that says "Use default". Now browse to the directory that will contain your class library. When you're done, click "OK".


Working With Art Resources

Unfortunately, Eclipse doesn't give you any capabilities for drawing MovieClips, and doesn't give you access to the Library. So if your project needs to have vector art, your best bet is to draw your MovieClips in the Flash Authoring Tool. Then, you have a couple of ways to get to your assets into FAME.

I. Use LoadMovie.
Here is a simple example of creating a clip and then loading and manipulating it in FAME.

1. Open the Flash Authoring Tool and create a new FLA called loadMe.fla.

2. Draw a filled circle on the stage. Then convert it to a MovieClip the usual way. (Select the art, then use the Modify/Convert To Symbol... menu item.)

3. Name your MovieClip "ball", and click "OK". Nothing else in the Convert to Symbol dialog needs to be checked.

4. Publish "loadMe.swf". Note that your MovieClip instance should still be on the stage, and should appear when you publish.

5. In Eclipse, create a new ActionScript2 Project. (For this example it's called "firstAS".) Copy loadMe.swf" into the root of your project folder.

6. In your src folder, create a new ActionScript2 Class called Paste the following code into the class code that's auto-generated:

function SimpleLoader(scope:MovieClip) {

//Main Entry Point
static function main() {
   var simpleLoader:SimpleLoader = new SimpleLoader(_root);

7. Create a new file called simpleLoader.flashout in the root of your project folder.

8. In Flashout, go to "Compilation status/preferences" and click the "SWF" tab. Supply the following paths...
Path to swf: [project path]/simpleLoader.swf
Root (main) class: [project path]/src/

9. In Flashout's "Additionals" tab, supply a "-header" parameter for MTASC.
additional params for compilation: -header 640:480:20

10. Click "Compile". You should see your ball SWF loaded in.

II. Inject Code Into An Existing SWF
Instead of having MTASC build a new SWF from scratch, here's an example of how you can add MTASC compiled code to an existing SWF.

1. Open the Flash Authoring Tool and create a new FLA called asset.fla.

2. Select Insert/New Symbol...

3. Call your symbol "ball". Make sure "Export for ActionScript" is checked. Then click OK.

4. Draw a filled circle in the MovieClip. For convenience, make sure it is aligned to (0,0) in the properties.

5. Publish the SWF. There's nothing on the stage yet, so it will be blank.

6. In Eclipse, create a new ActionScript2 Project. (For this example it's called "firstAS".) Copy asset.swf into the root of your project folder.

7. In your src folder, create a new ActionScript2 Class called Paste the following code into the class code that's auto-generated:

public var scope: MovieClip;

function Inject(tgt:MovieClip) {
   scope = tgt;
   scope.attachMovie("ball", "theball", scope.getNextHighestDepth(), {_x: 100, _y: 100});

// --- Main Entry Point
   static function main() {
var inject:Inject = new Inject(_root);

8. Create a new file called inject.flashout in the root of your project folder.

9. In Flashout, go to "Compilation status/preferences" and click the "SWF" tab. Supply the following paths...
Path to swf: [project path]/asset.swf
Root (main) class: [project path]/src/

10. IMPORTANT: Do not supply a "-header" parameter for MTASC! "-header" creates a new SWF. For this example, the Additionals field should be left blank.

11. Click "Compile". Your ActionScript code will be injected into the SWF.

If you're feeling adventurous, you might want to check out SWFMill, a tool for converting SWFs to XML. Some people have reported success integerating it with Eclipse.

IV. Use Bitmap Art
If you're not wedded to vector graphics, you could load bitmap images created in Photoshop or some other image editing program. Flash 8 is going to have some nice bitmap manipulation features, so you might want to take advantage of those.

Ultimately, your workflow will depend on what you need to accomplish. And,the truth of the matter is that if you really are creating a graphically-heavy SWF, you may be better off working in the Flash Authoring Tool for now.

A final warning: if you're loading in SWFs created in the Flash Authoring Environment, you should avoid putting code in them. Your code should be centralized, and, now that you're a FAME Developer, you should be centralizing your code in Eclipse! Also, there might be unpredictable side-effects involved in running an SWF with both MTASC and Macromedia Compiler code in it. However, if you absolutely must use both, you should probably pass the "-keep" parameter into MTASC. (Read up more about it on their website.)


fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'jquery-uisdk'));