### Installing SWF Library via Haxelib Source: https://github.com/openfl/swf/blob/master/README.md Provides instructions for installing the SWF library using the Haxelib package manager. This is the standard method for adding the library to a Haxe development environment and can be followed by adding the library to a Lime or OpenFL project's configuration file. ```bash haxelib install swf # Add to project file (e.g., project.xml): # ``` -------------------------------- ### Setting up Development Build of SWF Library Source: https://github.com/openfl/swf/blob/master/README.md Details the steps required to use a local development version of the SWF library instead of a release build. This involves cloning the repository, telling haxelib to use the local path for development, and then rebuilding the library tools. ```bash git clone https://github.com/openfl/swf haxelib dev swf swf # Rebuild tools: openfl rebuild tools # or cd swf haxe rebuild.hxml # To return to release builds: haxelib dev swf ``` -------------------------------- ### Command-Line SWF Processing to Animate ZIP Source: https://context7.com/openfl/swf/llms.txt Utilizes the `swf` haxelib command-line tool to convert SWF files into the optimized Animate ZIP format. Supports processing single files, custom output paths, entire directories, or all SWF files in the current directory. ```bash # Process single SWF file (creates test.zip in same directory) haxelib run swf process test.swf # Process with custom output path haxelib run swf process test.swf output/test.zip # Process with output directory (creates test.zip in specified folder) haxelib run swf process test.swf output/path # Process entire directory of SWF files haxelib run swf process path/to/swfs # Process all SWF files in current directory haxelib run swf process ``` -------------------------------- ### Loading Processed SWF Assets with AnimateLibrary Source: https://github.com/openfl/swf/blob/master/README.md Shows how to load SWF assets that have been processed into the Animate ZIP format. This involves using `AnimateLibrary.loadFromFile` and then obtaining movie clips from the loaded library. Alternatively, the loaded library can be registered with OpenFL's Assets manager for consistent access. ```haxe import swf.exporters.animate.AnimateLibrary; import openfl.utils.Assets; ... AnimateLibrary.loadFromFile("path/to/test.zip").onComplete(function(library) { var clip = library.getMovieClip("MyMovieClipName"); // or Assets.registerLibrary("my-swf", library); var clip = Assets.getMovieClip("my-swf:MyMovieClipName"); }); ``` -------------------------------- ### Runtime SWF Loading with SWFLibrary Source: https://context7.com/openfl/swf/llms.txt Loads SWF content at runtime using `SWFLibrary`, providing features for progress tracking, error handling, and asset retrieval. Supports loading by name and retrieving various asset types like MovieClips and Images. ```haxe import swf.SWFLibrary; import openfl.display.MovieClip; import openfl.events.Event; import openfl.events.IOErrorEvent; import openfl.events.ProgressEvent; var library = new SWFLibrary("my-game-assets"); // Load the library with progress tracking library.load().onProgress(function(loaded:Int, total:Int) { var percent = Math.round((loaded / total) * 100); trace("Loading: " + percent + "%"); }).onError(function(error:String) { trace("Error loading SWF: " + error); }).onComplete(function(lib) { trace("SWF library loaded successfully"); // Check if asset exists if (library.exists("Hero", "MOVIE_CLIP")) { var hero:MovieClip = library.getMovieClip("Hero"); addChild(hero); } // Get image from library var backgroundImage = library.getImage("Background"); var bitmap = new Bitmap(BitmapData.fromImage(backgroundImage)); addChild(bitmap); }); ``` -------------------------------- ### Load Animate Library from File or Bytes Source: https://context7.com/openfl/swf/llms.txt Loads processed Animate ZIP files at runtime, providing full symbol access. Supports loading from a file path or from byte arrays. Registered libraries are accessible globally via the Assets API. ```haxe import swf.exporters.animate.AnimateLibrary; import openfl.utils.Assets; import openfl.display.MovieClip; // Load from file path AnimateLibrary.loadFromFile("assets/animation.zip").onComplete(function(library) { trace("Animate library loaded"); // Create movie clip directly from library var character:MovieClip = library.getMovieClip("PlayerCharacter"); addChild(character); character.x = 100; character.y = 200; character.play(); // Register with Assets for global access Assets.registerLibrary("game-animations", library); // Now accessible through Assets API var enemy = Assets.getMovieClip("game-animations:EnemySprite"); addChild(enemy); }); // Load from bytes var zipBytes = Assets.getBytes("animation.zip"); AnimateLibrary.loadFromBytes(zipBytes).onComplete(function(library) { var clip = library.getMovieClip("MenuButton"); addChild(clip); }); ``` -------------------------------- ### Registering SWF Files in OpenFL Projects Source: https://context7.com/openfl/swf/llms.txt Integrates SWF files as libraries within OpenFL projects using the `project.xml` configuration. Allows seamless access to movie clips and other assets via the OpenFL Assets class. Supports generating Haxe classes for symbols for direct instantiation. ```haxe // In project.xml: // // import openfl.Assets; import openfl.display.MovieClip; // Access movie clip from library by ID var clip:MovieClip = Assets.getMovieClip("animation:CharacterWalk"); addChild(clip); // Access root timeline with empty symbol name var fullAnimation:MovieClip = Assets.getMovieClip("animation:"); addChild(fullAnimation); // Generate Haxe classes for symbols (add generate="true" to library tag) // var hero = new HeroCharacter(); // Uses exported class addChild(hero); ``` -------------------------------- ### Access AnimateLibrary Symbols and Metadata Source: https://context7.com/openfl/swf/llms.txt Programmatically enumerates and accesses contents within an AnimateLibrary. Allows checking for symbol existence, retrieving MovieClip and Image symbols, and determining if assets are locally stored. ```haxe import swf.exporters.animate.AnimateLibrary; AnimateLibrary.loadFromFile("assets/ui.zip").onComplete(function(library) { // List all available symbols var symbols = library.list("MOVIE_CLIP"); for (symbolName in symbols) { trace("Available symbol: " + symbolName); } // Check if specific symbol exists if (library.exists("Button", "MOVIE_CLIP")) { var button = library.getMovieClip("Button"); addChild(button); // All assets are local (no streaming) trace("Is local: " + library.isLocal("Button", "MOVIE_CLIP")); // true } // Access bitmap symbols if (library.exists("Logo", "IMAGE")) { var logoImage = library.getImage("Logo"); var bitmap = new Bitmap(BitmapData.fromImage(logoImage)); addChild(bitmap); } // Get empty string for root timeline var rootClip = library.getMovieClip(""); addChild(rootClip); }); ``` -------------------------------- ### Loading SWF Content from Bytes Source: https://context7.com/openfl/swf/llms.txt Parses a SWF file directly from ByteArray, allowing access to symbols and creation of display objects. It supports event listeners for completion, symbol existence checks, bitmap retrieval, and timeline access. Requires importing necessary OpenFL and SWF modules. ```haxe import openfl.utils.ByteArray; import openfl.Assets; import swf.SWF; // Load SWF from file bytes var swfBytes:ByteArray = Assets.getBytes("path/to/file.swf"); var swf = new SWF(swfBytes); // Listen for completion (required for Flash target with bitmap loading) swf.addEventListener(Event.COMPLETE, function(e:Event) { trace("SWF loaded successfully"); trace("Dimensions: " + swf.width + "x" + swf.height); trace("Frame rate: " + swf.frameRate); trace("Background: 0x" + StringTools.hex(swf.backgroundColor)); }); // Check if symbol exists if (swf.hasSymbol("MyCharacter")) { var movieClip = swf.createMovieClip("MyCharacter"); addChild(movieClip); } // Get bitmap data from symbol var bitmap = swf.getBitmapData("MyBitmapSymbol"); if (bitmap != null) { var image = new Bitmap(bitmap); addChild(image); } // Access entire timeline var timeline = swf.createMovieClip(""); addChild(timeline); ``` -------------------------------- ### Processing SWF Files from Command Line Source: https://github.com/openfl/swf/blob/master/README.md Illustrates the command-line usage of the SWF library for processing SWF files. The 'process' command can take a single SWF file, multiple SWF files, or specify output paths for the processed assets. Processed files are typically converted into a ZIP archive format compatible with OpenFL. ```bash haxelib run swf process haxelib run swf process path/to/swfs haxelib run swf process test.swf haxelib run swf process test.swf path/to/test.zip haxelib run swf process test.swf output/path ``` -------------------------------- ### Implement Custom SWFLoader for Display Object Loading Source: https://context7.com/openfl/swf/llms.txt Enables custom loading of SWF content in OpenFL 9.5+ using SWFLoader. Supports loading SWF files from URLs or byte arrays, providing access to loaded display objects and their properties. ```haxe import swf.SWFLoader; import openfl.display.Loader; import openfl.net.URLRequest; import openfl.events.Event; // Register SWF loader (OpenFL 9.5+ required) var loader = new Loader(); loader.contentLoaderInfo.contentType = "application/x-shockwave-flash"; var swfLoader = new SWFLoader(); // Load from URLswfLoader.load(new URLRequest("animation.swf"), null, loader.contentLoaderInfo) .onComplete(function(displayObject) { addChild(displayObject); trace("Width: " + loader.contentLoaderInfo.width); trace("Height: " + loader.contentLoaderInfo.height); trace("Frame rate: " + loader.contentLoaderInfo.frameRate); }); // Load from bytes var bytes:ByteArray = Assets.getBytes("game.swf"); swfLoader.loadBytes(bytes, null, loader.contentLoaderInfo) .onComplete(function(content) { addChild(content); content.play(); }); ``` -------------------------------- ### Loading SWF MovieClip Assets in OpenFL Source: https://github.com/openfl/swf/blob/master/README.md Demonstrates how to load SWF movie clips as assets within an OpenFL project. This can be done directly by specifying the SWF name and movie clip name, or by using a custom ID. If the 'generate' option was used during SWF processing, movie clips can be instantiated directly as Haxe classes. ```haxe var clip = Assets.getMovieClip("my-swf:MyMovieClipName"); // Or, to create the whole timeline: var timeline = Assets.getMovieClip("my-swf:"); // If 'generate' option was used: // var clip = new MyMovieClipName(); ``` -------------------------------- ### Access SWF Data Properties Source: https://context7.com/openfl/swf/llms.txt Provides access to parsed SWF metadata and properties after loading SWF data. Includes stage dimensions, frame rate, background color, symbol mapping, and underlying SWF data structure details. ```haxe import swf.SWF; import openfl.utils.ByteArray; var swfBytes:ByteArray = Assets.getBytes("movie.swf"); var swf = new SWF(swfBytes); swf.addEventListener(Event.COMPLETE, function(e:Event) { // Access SWF properties trace("Stage dimensions: " + swf.width + " x " + swf.height); trace("Frame rate: " + swf.frameRate + " fps"); trace("Background color: #" + StringTools.hex(swf.backgroundColor, 6)); // Access symbol map for (symbolName in swf.symbols.keys()) { var characterId = swf.symbols.get(symbolName); trace("Symbol: " + symbolName + " (ID: " + characterId + ")"); } // Access underlying SWF data structure var frameSize = swf.data.frameSize; var tagCount = swf.data.tags.length; trace("Total tags: " + tagCount); trace("SWF version: " + swf.data.version); trace("Frame count: " + swf.data.frameCount); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.