Noticed you can expand an SWF file in the Project pane in FlashDevelop. A compiled openfl swf has a “Classes” subtree. My Vectorian Giotto swf does not have one, only “Properties” and “Fonts” and I see nothing that would seem applicable in them.
In VG I found that I can right-click Layer 1 and go Convert to Symbol, after which it appears in the Library pane. From there I can right-click it and choose Properties, where I can enter a class name and identifier.
These then show up in FlashDevelop’s project pane under the swf’s Symbols subtree (as the identifier and “Frame 0”). But I still can’t just use var clip = new TestClass();
because the compiler complains that TestClass
doesn’t exist. Indeed, it didn’t seem to be auto-generated.
With the “standard” method instead of the preload/generate, it compiles, but crashes immediately:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChild()
at MethodInfo-9()[C:\haxe-projects\New Project\src\Main.hx:24]
at lime.app::Promise/complete()[C:\HaxeToolkit\haxe\lib\lime\2,9,0\lime\app\Promise.hx:32]
at lime.app::Promise/complete()[C:\HaxeToolkit\haxe\lib\lime\2,9,0\lime\app\Promise.hx:32]
at MethodInfo-238()[C:\HaxeToolkit\haxe\lib\swf\2,2,0\format\swf\SWFLibrary.hx:153]
This is with either var clip = Assets.getMovieClip ("test:TestID");
or var clip = Assets.getMovieClip ("test:TestClass");
.
The closest I seem to have gotten is trying this:
class Main extends Sprite
{
public function new()
{
super();
//var clip = new TestClass();
//addChild (clip);
Assets.loadLibrary ("test", function (_) {
var clip = Assets.getMovieClip ("test:");
addChild (clip);
});
}
}
…i.e., test:
without any class name, to load the whole exported SWF, which was a simple drawing with an animation effect added. Instead of a null pointer compiler error, it compiles fine but then crashes immediately on the line return cast loader.content;
of getMovieClip
:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@5133f31 to flash.display.MovieClip.
at format.swf::SWFLibrary/getMovieClip()[C:\HaxeToolkit\haxe\lib\swf\2,2,0\format\swf\SWFLibrary.hx:121]
at openfl::Assets$/getMovieClip()[C:\HaxeToolkit\haxe\lib\openfl\3,6,0\openfl\Assets.hx:219]
at MethodInfo-9()[C:\haxe-projects\New Project\src\Main.hx:23]
at lime.app::Promise/complete()[C:\HaxeToolkit\haxe\lib\lime\2,9,0\lime\app\Promise.hx:32]
at lime.app::Promise/complete()[C:\HaxeToolkit\haxe\lib\lime\2,9,0\lime\app\Promise.hx:32]
at MethodInfo-238()[C:\HaxeToolkit\haxe\lib\swf\2,2,0\format\swf\SWFLibrary.hx:153]
This error also happens if I make the SWF consist of only an oval, converted to symbol as MovieClip, Export for ActionScript, with no animation.
I tried with or without “Export in first frame” on the symbol properties in VG, with or without “Compress movie” during swf export in VG, and also converting my oval to either a MovieClip or a Button symbol.
This is apparently covered by many of these questions: http://stackoverflow.com/search?q=AVM1Movie Unfortunately, none of them seem haxe-specific. For example, there’s ForcibleLoader.as out in the wild, but I don’t think I can make use of it in a haxe project. How can I use a AVM1Movie object in OpenFL? I couldn’t find any examples online, and the documentation doesn’t give many details about them (understandably, since they’re considered legacy.)
I also tried putting this in project.xml, but it made no difference:
<haxeflag name="-swf-lib" value="assets/img/test.swf" if="flash" />
<haxeflag name="-swf-version" value="8" if="flash" />