fluby

A simple command to create an empty ActionScript project for MTASC + SWFMILL + Rake

Installation

gem install fluby

Fluby requires the 'mtasc' and 'swfmill' executables somewhere on your path.

Usage

New project

To create a new project:

fluby ProjectName

Compilation

To compile your brand new project:

cd ProjectName
rake

That should generate a 'ProjectName.swf' file on the 'deploy' folder. The SWF file is debug-enabled (i.e: you can see the trace() output if you have a debug Flash Player). If you want to release your project without debug information, run

rake release

More Rake tasks

There are other rake tasks available:

rake package  # Creates a ZIP file containing your SWF file on the 'pkg' folder
rake test # Opens a HTML file with your SWF for testing on your default browser (available on Mac only)

script/generate

Starting from version 0.6, fluby installs a 'generate' script in the 'scripts' folder that you can use to speed up the creation of new classes.

Right now there are 3 template types:

class

Use it to create a generic class by running:

script/generate class your.class.path.ClassName attribute:Type attribute:Type (...)

For example: if you want to create a "Car" class with attributes "make" and "model" of type String and an attribute "year" of type Number, you'd run:

script/generate class com.yourdomain.Car make:String model:String year:Number

This will create a file in com/yourdomain/Car.as with this content:

class com.yourdomain.Car {
  var make:String;
  var model:String;
  var year:Number;
  function Car(){
    // Init class
  }
}

xml_loader

Use to create a simple XML loader class by running:

script/generate xml_loader your.class.path.ClassName

Example: if you run

script/generate xml_loader com.bomberstudios.xml.Loader

you'll get a com/bomberstudios/xml/Loader.as file containing:

class com.bomberstudios.xml.Loader {
  var _path:String;
  var raw_data:XML;
  function Loader(path:String,callback:Function){
    _path = path;
    raw_data = new XML();
    raw_data.ignoreWhite = true;
    raw_data.onLoad = callback;
  }
  function give_me(node_name){
    if (raw_data.firstChild.nodeName == node_name) {
      return raw_data.firstChild;
    }
    for(var i=raw_data.firstChild.childNodes.length; i>=0; i--){
      if(raw_data.firstChild.childNodes[i].nodeName == node_name){
        return raw_data.firstChild.childNodes[i];
      }
    }
  }
  public function load(){
    raw_data.load(_path);
  }
}

delegate

To generate a MTASC-compatible Delegate class, run

script/generate delegate your.class.path.Delegate

This will produce a your/class/path/Delegate.as file containing:

/**
*
* Delegate Class, MTASC compatible
*
**/
class your.class.path.Delegate {
  public static function create(scope:Object,method:Function):Function{
    var params:Array = arguments.splice(2,arguments.length-2);
    var proxyFunc:Function = function():Void{
      method.apply(scope,arguments.concat(params));
    }
    return proxyFunc;
  }
  public static function createR(scope:Object,method:Function):Function{
    var params:Array = arguments.splice(2,arguments.length-2);
    var proxyFunc:Function = function():Void{
      method.apply(scope,params.concat(arguments));
    }
    return proxyFunc;
  }
}