12 May 2005

I finally found some more time to play with FAME and got Flashout working (thanks to Alex's tip on using the -clean option to make Eclipse see the plugin on my Windows machine.) Skimming through Carlos Rovira's excellent introduction to FAME (Towards Open Source Flash Development) was very helpful but I did notice something in the test code that I would do differently.

In the article, the sample document class Test looks like this:

ActionScript:
  1. class Test {
  2.  
  3. private var scopeRef:MovieClip;
  4. function Test(scope:MovieClip) {
  5. scopeRef = scope;
  6. // --- Creates a 'tf' TextField size 100x600 at pos 100, 100
  7. scopeRef.createTextField("tf", 0, 100, 100, 800, 600);
  8. // --- Write some text into it
  9. scopeRef.tf.text = "Hello FlashWeek!!!!";
  10. }
  11. // --- Main Entry Point
  12. static function main() {
  13. var test:Test = new Test(_root);
  14. }
  15. }

The static main function (the entry point) instantiates the Test class' constructor and passes a reference to _root, which the Test instance uses when creating the text field. I would do this a little differently, like this:

ActionScript:
  1. class Test extends MovieClip
  2. {
  3. private var tf:TextField;
  4. function Test(scope:MovieClip)
  5. {
  6. // Redefine scope
  7. this = scope;
  8. // Creates a TextField sized 100x600 at pos 100, 100
  9. createTextField("tf", 0, 100, 100, 800, 600);
  10. // Write some text into it
  11. tf.text = "Hello FlashWeek!!!!";
  12. }
  13. // Main Entry Point
  14. static function main()
  15. {
  16. var test:Test = new Test(_root);
  17. }
  18. }

The nice thing about this doing things this way is that your Test class actually does extend MovieClip and you retain the ability to define your stage elements as members of your class and thus take advantage of compile-time error checking.

By the way, FAME *is* very cool indeed!

Creative Commons LicenseThe Finally, FAME! article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.

Add Your Comment

Spam Protection by WP-SpamFree

Finally, FAME!

  1. Dude, check out line numbers!!!

    Look at the picture below the code to see what I mean… TRACE rocks!

    http://www.jessewarden.com/archives/2005/05/fame_chronicles_1.html

    JesterXL
  2. Hi Aral,

    Good to see you trying and enjoying FAME. I like your new approach to application init code too. Although I think both approachs are welcome as not always we need to inherith from MovieClip and make our application mc-dependent in each application view.

    I think both are good practices and you must apply each one depending on your application’s necessity.

    Carlos Rovira
  3. Hey Jesse — yeah, I saw your article — very cool indeed. The ability to override trace has been on the wishlist of many people for a long time!

    @Carlos: Regarding not making views inherit from MovieClip — I can’t think of any scenario where a view (in a Flash application) would not inherit from MovieClip (even if it extends, say, UIObject or some other form class, those would extend MovieClip, no?) Am I missing a potential use case?

    Aral Balkan
  4. Hi Aral,

    I used this sort of approach in my MXDU 2003 flash GIS application and I’m currently toying with it as the basis of a lightweight UI framework (yet another one).
    You asked for a potential use case where a view wouldn’t extend MovieClip. In my toy framework there is only one symbol containing a bounds rectangle and each view instance “has-a” reference to an instance of the symbol on the stage.
    The view classes aren’t movie clips – movie clips are specific to things on the stage of a Flash application, the views are more abstract and represent rectangular areas we can draw on and receive user interactions through – the methods and events might be the same or similar to a movie clip but the implementation of the methods could change – examples might include publishing the drawing commands to / accepting click and change events from an FCS stream (Flash VNC anyone?) or implementing an Excel-like “freeze panes” scroll view where one view is rendered on four movie clips with independant masks and scroll positions.
    So, while most Flash application views will be movie clips, it doesn’t have to be the case all the time, in fact there is a fairly rich vein of possibilities to explore when you consider separating the two.

    robin
  5. Hi Robin,

    Thanks for the use cases — I can definitely see how it would be useful to use composition to add a level of abstraction in the manner you described — I’m just not sure whether the reference to the symbol you described belongs in your view or in your controller. eg. When you mention publishing drawing commands to or accepting click events from FCS — that sounds very much like business logic to me. What you do with these (eg. updating the presentation as a result of click events from FCS) are definitely view-related.

    Aral Balkan
  6. I´ve tryed to use the same code here but I get >>>>

    type error MovieClip should be XMLExposer2 at line >>> this = scope

    João Carlos

    joão carlos
  7. excuse me:

    type error MovieClip should be Test

    at line >>> this = scope

    João Carlos
  8. Hi — I believe certain things changed in MTASC/Swfmill since this post. I will schedule some time to look into updating the older posts.

    Aral Balkan
  9. Also note that FAME/FAMES isn’t really supported by the open source community anymore as Flashout is not open source. It’s AMES now! :)

    In other words:

    ASDT + Ant (The A is overloaded) :)
    MTASC
    Eclipse
    Swfmill

    Viva AMES!

    Aral Balkan
  10. I’m still wondering what “FAME” is?
    Time for a Google search…

    Ah, it’s an open source code solution. I’ve seen a lot of those. FAME isn’t fully open source, so I’m recommended to check AMES, but if Flashout is free, I don’t see any big problem with FAME or FAMES. Still, I don’t see much reason to use that stuff if you want a free animation tool. The best thing about the Flash IDE is how convenient it is. You load it and it has everything you need to make a game or an animation. If there’s an open source alternative to the Flash IDE, I’d love to see it, but everything I’ve seen focuses on the coding only.

    Josh