Muzak, I have used Cairngorm for Flex 2 applications and I see that ARP is very very similar to it, but before I get myself and my other developer involved with ARP (on a non-forms based app), is there anything tricky I need to know about developing ARP apps without Forms, since their documentation focuses on Form development?
Any help or links are greatly appreciated! Cheers! On 4/23/07, Muzak <[EMAIL PROTECTED]> wrote:
In FCS 3 you'll be able to specify a class for the "_root" of an swf. In Flash 8 and previous Flash versions there's no such option. One way to deal with this is the MTASC-way (code taken from http://www.mtasc.org/#usage) class Tuto { static var app : Tuto; function Tuto() { // creates a 'tf' TextField size 800x600 at pos 0,0 _root.createTextField("tf",0,0,0,800,600); // write some text into it _root.tf.text = "Hello world !"; } // entry point static function main(mc) { app = new Tuto(); } } When compiling with MTASC you can then specify the name of your "main" class (Tuto.as) and which method to call on the class --> in this case "main()" mtasc -swf tuto.swf -main -header 800:600:20 Tuto.as So what it does when you compile is invoke: Tuto.main(); The code looks a bit odd though, since main() seems to accept an argument (mc) but it doesn't seem to get used and the constructor simply uses _root as the target (which IMO isn't a good idea). Without MTASC you could do the following: class Tuto { static var app : Tuto; private static var target:MovieClip; function Tuto() { // creates a 'tf' TextField size 800x600 at pos 0,0 target.createTextField("tf",0,0,0,800,600); // write some text into it target.tf.text = "Hello world !"; } // entry point static function main(mc:MovieClip) { target = mc; app = new Tuto(); } } And in the main timeline you'd call: Tuto.main(this); On top of that, when not using MTASC, you can simply dump the static method entry point and use the "new" keyword class App{ private var target:MovieClip; function App(mc:MovieClip) { target = mc; target.createTextField("tf",0,0,0,800,600); target.tf.text = "Hello world !"; } } And in the main timeline: var app:App = new App(this); Ofcourse, to actually create a whole application, you'd do something else in the class constructor instead of simply creating a TextField. Then there's the ARP way of doing things - which is what I use ;-) http://osflash.org/arp/ Instead of using the main timeline as the "root" of your application, you create a movieclip with a class assigned to it and place it on stage. This MovieClip+Class is usually called "Application". The rest of the flash app goes inside the Application MovieClip. By placing the Application movieclip on stage, you don't have to call anything from the main timeline to start the app. This is very similar to creating a "Flash Form Application" fla by the way, except that you're not forced to use the v2 Framework (mx.screens.Form). But the overall idea is the same: you create a tree-structure with the Application Class/MovieClip as the main timeline and the Application takes care of which child movieclip is shown/hidden. regards, Muzak ----- Original Message ----- From: "Johan Nyberg" <[EMAIL PROTECTED]> To: <flashcoders@chattyfig.figleaf.com> Sent: Monday, April 23, 2007 2:09 PM Subject: [Flashcoders] Basic "class for swf"-question > Hi, just wanted to know if there is a best practice when creating a class for the mother movie (i.e. the flash-movie itself). Is > this the way to go? > > var mother:MyFabFlashApp = new MyFabFlashApp(); > > ..or is there a better way? Seems kind of a stupid question, but I wanted to put it anyway in case I've missed something. ;-) I've > put my main code on the first frame of the _root timeline for too long, and want to move it into a class. > > > Regards, > > /Johan > > -- > Johan Nyberg _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
-- Jordan Snyder Applications Developer Image Action LLC http://www.imageaction.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com