Codename Logo Codename Logo

Custom Classes

APIWikiTools

Custom Classes

Custom classes can be made either inside the script you need it in or you can make a script file corresponding with the name of the class in ./source, and using import to import it.

Here is a basic Song Script code that uses it:

package; // Allow `package` declaration. Ignored by the interpreter.

class SpecialSprite extends FlxSprite {
  public static function getSprite(v:String) {
    return new SpecialSprite(v);
  }

  public var customValue(default, set):String = null;
  private function set_customValue(v:String):String {
      if(v == "powerful") 
          trace("I'm powerful!");
      loadGraphic(Paths.image(v));
      return customValue = v;
  }  
        
  public function new(customValue:String) {
      super(200, 400, null);
      this.customValue = customValue;
      //other code stuff
  }

  public override function update(elapsed) {
      super.update(elapsed);
  }
}

function create() {
  var spr = SpecialSprite.getSprite("powerful");
  add(spr);
}

Particularities

As of writing this, this system is limited and also presents some defects. For example:

Written by: Ne_Eo, Frakits & Jamextreme140
Last updated: 2025-09-19