[TxMt] AS2- How do I target my root MC when using MTASC?

Ale Muñoz bomberstudios at gmail.com
Fri May 23 21:46:31 UTC 2008


If you are using the -main flag in MTASC (if you are using the AS2
bundle it's on by default) your main() method will be called with a
parameter, like this:

class YourApp {
  static function main(mc:MovieClip){
    // mc is the Stage, equivalent to _root most of the time.
  }
}

Thus, you can target _root by setting a variable in your class when it
is initialized.

Here's the skeleton for 99% of my AS2 projects:

class Foo {
  var _timeline:MovieClip;
  function Foo(timeline){
    _timeline = timeline;
  }
  static function main(tl:MovieClip){
    var app:Foo = new Foo(tl);
  }
}

For more info, I'd suggest checking the MTASC list:
http://lists.motion-twin.com/mailman/listinfo/mtasc

About MTASC not being developed anymore... the project is alive, and
the maintainer is rather active on the mailing list. The thing is
MTASC is pretty much finished (it's solid as a rock, fast, and no
known bugs exist on the code) and AS2 is not going to change, so
there's no reason for development to "happen" : )

If you already know AS2 or need to mantain "old" code, there is no
reason not to use MTASC.


-- 
Ale Muñoz
http://sofanaranja.com
http://bomberstudios.com


More information about the textmate mailing list