I mainly use Adobe Animate to create animations
I would like to ask when the author will update the SWF library again?
I am looking forward to it
Yeah, everyone is looking forward to it
Last time I asked, the SWF library doesn’t work on Flash and Air platforms
Last time, the producer sent me a post asking me to install instructions and merge files? But I still don’t know how to do it! I urgently need help
Newcomers who encounter problems post asking for help
If using the Flash/AIR targets, they should be able to load external swf files created by Animate. Not sure if this helps but here is how you would do that and then pull out a MovieClip with a certain name. You could have many different animations in the same swf this way.
package;
import openfl.display.Sprite;
import openfl.display.MovieClip;
import openfl.display.Loader;
import openfl.events.Event;
import openfl.Assets;
import openfl.system.LoaderContext;
import openfl.system.ApplicationDomain;
class Main extends Sprite {
public function new () {
super ();
//Assumes the asset with linkage set to "LittleBoy" is in the swf file. Change as required.
//Assumes that the swf file is in the assets folder with embed set to true
loadSwfMovie("assets/swflibrary.swf", this, "LittleBoy");
}
function loadSwfMovie(thePath:String, holder:Sprite, assetName:String):Void {
trace("adding a swf file asset");
var bytes = Assets.getBytes(thePath);
var mc:MovieClip;
var context = new LoaderContext (false, ApplicationDomain.currentDomain, null);
context.allowCodeImport = true;
var loader = new Loader ();
loader.contentLoaderInfo.addEventListener (Event.COMPLETE, function (_) {
trace("done:"+loader.content);
mc = cast Type.createInstance (ApplicationDomain.currentDomain.getDefinition (assetName), []);
trace("mc:"+mc);
addChild(mc);
});
loader.loadBytes(bytes, context);
}
}
Note that the SWF format is highly compressed. It is possible to “zip” it and actually make it larger. So you may not need any sort of zip compression like you asked elsewhere. Not sure your use case though.
Thank you for your answer. I am trying to develop a project using OpenFL, and the platforms I need to release are mainly HTML5 and Windows exe. I also need to release APK Flash and Air
Does your code also work on other target platforms? I need a code to publish multiple target platforms
If I don’t use the SWF library, my large number of sequence frame images would need to be packaged into a zip file, but I don’t know how to retrieve my images from the zip file
I only want to use OpenFL, I don’t need any other frameworks!
I don’t need a Pok é mon watch! Because OpenFL does not have built-in sprite animations
Others may use Spine, but I mainly use Adobe Animate to create animations! I need to export my animation to all target platforms, including Flash and Air
No one pays attention to me. It seems that the best method currently is to load the spritesheet at runtime, then copy each image and save it to the array, and use bit.bitmapData to replace it later ..
I feel like I’ve lost the advantage of Adobe Animation in creating animations!
Keep in mind we’re all on different time zones…
For non-Flash, my experience involves creating a bundle file using openfl process theLibrary.swf
. Then:
var swflib="assets/"+swflib+".bundle";
//AssetLibrary.loadFromFile needs a manifest file or bundle, not a swf file
var libName = "myLib";
var basePath = "/";
AssetLibrary.loadFromFile (swflib,basePath).onComplete( function (library:AssetLibrary) {
Assets.registerLibrary (libName, library);
trace ("SWF library loaded");
});
//after that:
trace("adding a .bundle movieclip");
var mc = Assets.getMovieClip ("myLib:" + "LittleBoy");
addChild(mc);
Keep in mind you could switch between the first solution and the second one using conditional compilation:
#if flash
// first solution
#else
//second solution
#end
This is the SWF library, which does not work on Flash and Air target platforms! As I mentioned before, your method is based on the old version of the SWF library.
I’m Chinese, and it’s 1.34 in the middle of the night. Yes, I’m staying up late again