Lime 8.0.0 and OpenFL 9.2.0 Release

OpenFL 9.2.0 also adds a new @:bind syntax that enables you to define your own custom base classes in Haxe that bind with symbols you have defined in a SWF or Adobe Animate project. This has been a long requested feature and a super-awesome, super-important improvement for you SWF lovers out there!

Step 1 – Export for ActionScript

In Adobe Animate, choose a class name and leave the base class alone as flash.display.MovieClip (this is required for Animate to properly compile your SWF).

Step 2 – Create a Haxe base class

You can simply use @:bind if your Haxe base class has the same name as what you used in Animate.

package com.my;

import openfl.display.MovieClip;

@:bind class BindClass extends MovieClip
{
    public function new()
    {
        super();
        trace("Hello from my base class!");
    }
}

You can also use the @:native meta-data tag if your Haxe class name does not match up with the one specified within Adobe Animate or your published SWF.

import openfl.display.MovieClip;

@:bind @:native("com.my.BindClass") class MyCustomBaseClass extends MovieClip
{
    public function new()
    {
        super();
        trace("Hello from my base class!");
    }
}

Step 3 – Create a new instance of your SWF symbol

If you have auto-class generation enabled for your SWF library (the default), you should be able to create a new instance of your symbol directly:

var symbol = new BindSymbol();

Otherwise you can also create an instance using openfl.utils.Assets

var symbol = Assets.getMovieClip("mylibrary:BindSymbol");

The @:bind syntax is especially useful because it works for symbols that are instantiated automatically as part of a timeline. Previously it was a giant headache to try and track-down every time one of these symbols were instantiated to try and attach the desired functionality to each copy. Now as they are instantiated, they will automatically link up to your bound base class, similar to how @:bind works with the built-in Haxe Flash target.

Remember, you need both the new version of the SWF library and OpenFL to work together for this feature. And if you decide to create your own asset libraries, OpenFL now includes the internal wiring to add @:bind syntax of your own. Asset libraries are a little-used (and super-powerful) feature that can create native MovieClips out of any resource type you can think of – spritesheets, tiles, flump, texturepacker, you name it – with a little elbow grease. I’d love to see more use of this feature

SWF 3.1.0 (08/31/2022)

  • Added support for OpenFL 9.2 @:bind to extend SWF symbol classes
  • Added support to extend Sprite classes (in addition to MovieClip)
  • Added initial support for SWC files
  • Added support for multiple labels per frame in Animate libraries
  • Improved MovieClip animation performance in Animate libraries
  • Improved class generation to allow generate="false" to disable
  • Fixed initialization order to allow extending generating classes
  • Fixed support for Assets.exists without specifying asset type
  • Fixed Std.is deprecation warnings
12 Likes