Finally, FAME!
In the article, the sample document class Test looks like this:
class Test { private var scopeRef:MovieClip; function Test(scope:MovieClip) { scopeRef = scope; // --- Creates a 'tf' TextField size 100x600 at pos 100, 100 scopeRef.createTextField("tf", 0, 100, 100, 800, 600); // --- Write some text into it scopeRef.tf.text = "Hello FlashWeek!!!!"; } // --- Main Entry Point static function main() { var test:Test = new Test(_root); } }
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:
class Test extends MovieClip { private var tf:TextField; function Test(scope:MovieClip) { // Redefine scope this = scope; // Creates a TextField sized 100x600 at pos 100, 100 createTextField("tf", 0, 100, 100, 800, 600); // Write some text into it tf.text = "Hello FlashWeek!!!!"; } // Main Entry Point static function main() { var test:Test = new Test(_root); } }
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!
The Finally, FAME! article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.

Subscribe to my blog






JesterXL
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
May 13th, 2005 at 1:31 amCarlos Rovira
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.
May 13th, 2005 at 8:21 amAral Balkan
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?
May 13th, 2005 at 10:59 amrobin
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).
May 14th, 2005 at 5:38 amYou 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.
Aral Balkan
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.
May 14th, 2005 at 10:28 amjoão carlos
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
February 16th, 2006 at 6:09 pmJoão Carlos
excuse me:
type error MovieClip should be Test
at line >>> this = scope
February 16th, 2006 at 6:10 pmAral Balkan
Hi — I believe certain things changed in MTASC/Swfmill since this post. I will schedule some time to look into updating the older posts.
February 18th, 2006 at 11:09 pmAral Balkan
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!
February 18th, 2006 at 11:10 pm