### Control GAF Animation Playback and Sequences (ActionScript 3) Source: https://context7.com/catalystapps/starlinggafplayer/llms.txt Provides MovieClip-like controls for `GAFMovieClip` instances, including basic playback functions like play, stop, gotoAndPlay, and gotoAndStop. It also supports sequence-based playback by setting named sequences and allows listening for sequence start and end events. Nested animations can be accessed and controlled individually by their instance names. ```actionscript import com.catalystapps.gaf.display.GAFMovieClip; import starling.events.Event; var movieClip: GAFMovieClip = new GAFMovieClip(timeline); // Assuming 'timeline' is already defined // Basic playback controls movieClip.play(true); // Play with looping movieClip.stop(); movieClip.gotoAndPlay(10); movieClip.gotoAndStop(5); // Sequence-based playback movieClip.setSequence("idle"); movieClip.setSequence("attack", true); // true to play immediately // Listen for sequence events movieClip.addEventListener(GAFMovieClip.EVENT_TYPE_SEQUENCE_START, onSequenceStart); movieClip.addEventListener(GAFMovieClip.EVENT_TYPE_SEQUENCE_END, onSequenceEnd); movieClip.addEventListener(Event.COMPLETE, onComplete); function onSequenceEnd(event: Event): void { trace("Sequence ended, switching to idle"); movieClip.setSequence("idle"); } // Access nested animations by instance name var nestedMC: GAFMovieClip = movieClip["characterHead"]; nestedMC.setSequence("blink"); ``` -------------------------------- ### Basic CSS for Full Height Layout Source: https://github.com/catalystapps/starlinggafplayer/blob/master/demo/bundle/bin/index.html Applies basic CSS to ensure the HTML and body elements take up the full viewport height and removes default body margin for a cleaner layout. ```css html, body { height:100%; } body { margin:0; } ``` -------------------------------- ### Configure GAF Converter Options (ActionScript) Source: https://context7.com/catalystapps/starlinggafplayer/llms.txt This ActionScript snippet shows how to configure the ZipToGAFAssetConverter for advanced options such as GPU memory management, asynchronous parsing, and texture format. It allows for fine-grained control over texture loading and conversion performance, which is crucial for optimizing GAF animations in various deployment scenarios. ```actionscript import com.catalystapps.gaf.core.ZipToGAFAssetConverter; import flash.display3D.Context3DTextureFormat; import starling.core.Starling; // Enable lost context handling for deferred loading Starling.handleLostContext = true; // Configure converter options var converter: ZipToGAFAssetConverter = new ZipToGAFAssetConverter("bundle_id"); // Set texture memory management strategy ZipToGAFAssetConverter.actionWithAtlases = ZipToGAFAssetConverter.ACTION_DONT_LOAD_IN_GPU_MEMORY; // Don't load textures yet // ZipToGAFAssetConverter.ACTION_LOAD_IN_GPU_MEMORY_ONLY_DEFAULT; // Load default scale only // ZipToGAFAssetConverter.ACTION_LOAD_ALL_IN_GPU_MEMORY; // Load all scales // Use compressed texture format to reduce memory converter.textureFormat = Context3DTextureFormat.BGRA_PACKED; // 16-bit textures // Enable async parsing to prevent UI freeze converter.parseConfigAsync = true; // Keep zip in memory for later use ZipToGAFAssetConverter.keepZipInRAM = true; // Ignore sounds if not needed converter.ignoreSounds = true; // Convert with specific scale and CSF converter.convert( zipData, 1.0, // defaultScale 2.0 // defaultContentScaleFactor for retina displays ); ``` -------------------------------- ### Convert GAF Zip to Playable Animation (ActionScript 3) Source: https://context7.com/catalystapps/starlinggafplayer/llms.txt Converts a GAF zip file from a ByteArray into a playable timeline object using `ZipToGAFAssetConverter`. This process automatically handles texture atlas loading, sound extraction, and bundle creation. The output is a `GAFBundles` object that can be used to create `GAFTimeline` and `GAFMovieClip` instances. Ensure the GAF zip file is correctly embedded as a ByteArray. ```actionscript import com.catalystapps.gaf.core.ZipToGAFAssetConverter; import com.catalystapps.gaf.data.GAFBundle; import com.catalystapps.gaf.data.GAFTimeline; import com.catalystapps.gaf.display.GAFMovieClip; import flash.events.Event; import flash.utils.ByteArray; // Embed the GAF animation [Embed(source="animation.zip", mimeType="application/octet-stream")] private const AnimationZip: Class; // Convert the animation var zip: ByteArray = new AnimationZip(); var converter: ZipToGAFAssetConverter = new ZipToGAFAssetConverter(); converter.addEventListener(Event.COMPLETE, onConverted); converter.convert(zip); function onConverted(event: Event): void { var bundle: GAFBundle = (event.target as ZipToGAFAssetConverter).gafBundle; var timeline: GAFTimeline = bundle.getGAFTimeline("animation_name"); var movieClip: GAFMovieClip = new GAFMovieClip(timeline); // Set playback options movieClip.play(true); // true for looping addChild(movieClip); } ``` -------------------------------- ### Manage GAF Timelines Globally with GAFTimelinesManager (ActionScript 3) Source: https://context7.com/catalystapps/starlinggafplayer/llms.txt Offers centralized management of all GAF bundles and timelines within an application using `GAFTimelinesManager`. This class allows registering GAF bundles, retrieving specific timelines or movie clips by name, and cleaning up resources by removing bundles. It simplifies access to animations across different parts of the application. ```actionscript import com.catalystapps.gaf.core.GAFTimelinesManager; import com.catalystapps.gaf.data.GAFBundle; import com.catalystapps.gaf.data.GAFTimeline; import com.catalystapps.gaf.display.GAFMovieClip; // Register a bundle after conversion (assuming 'converter' is the ZipToGAFAssetConverter instance) var bundle: GAFBundle = converter.gafBundle; GAFTimelinesManager.addGAFBundle(bundle, "characters"); // Retrieve timeline from anywhere in application var timeline: GAFTimeline = GAFTimelinesManager.getGAFTimeline( "character_animations", // SWF or GAF config name "walkCycle" // Linkage name in Flash library ); // Create movie clip instance directly var character: GAFMovieClip = GAFTimelinesManager.getGAFMovieClip( "character_animations", "jumpAnimation" ); // Clean up when done GAFTimelinesManager.removeAndDisposeBundle("characters"); ``` -------------------------------- ### Configure Global GAF Settings in Starling Source: https://context7.com/catalystapps/starlinggafplayer/llms.txt This ActionScript snippet shows how to configure library-wide settings for GAF animations using the static `GAF` class. These settings impact draw call optimization, sound playback, and texture settings across all GAF movie clips for improved performance. ```actionscript import com.catalystapps.gaf.data.GAF; // Optimize draw calls by setting alpha to 0.99 for opaque objects // Reduces draw calls when mixing transparent and opaque objects GAF.use99alpha = true; // Control automatic sound playback from animation events GAF.autoPlaySounds = false; // Enable mipmaps for smoother scaling GAF.useMipMaps = true; // These settings affect all GAFMovieClip instances ``` -------------------------------- ### Access GAF Timelines and Textures (ActionScript) Source: https://context7.com/catalystapps/starlinggafplayer/llms.txt This snippet demonstrates how to retrieve main and nested GAFTimelines from a GAFBundle using their linkage names. It also shows how to access custom regions for dynamic texture replacement and iterate through all timelines within a bundle. This is useful for dynamically loading and manipulating GAF animations. ```actionscript import com.catalystapps.gaf.data.GAFBundle; import com.catalystapps.gaf.data.GAFTimeline; import com.catalystapps.gaf.display.IGAFTexture; var bundle: GAFBundle = converter.gafBundle; // Get main timeline var mainTimeline: GAFTimeline = bundle.getGAFTimeline( "game_animations", // Config file name "rootTimeline" // Use "rootTimeline" for main timeline ); // Get nested timeline by linkage var explosionTimeline: GAFTimeline = bundle.getGAFTimeline( "game_animations", "explosion_sprite" ); // Access custom region (texture) for dynamic replacement var customTexture: IGAFTexture = bundle.getCustomRegion( "game_animations", "weapon_sprite", 1.0, // Scale 1.0 // Content scale factor ); // Get all timelines in bundle var allTimelines: Vector. = bundle.timelines; for each (var timeline: GAFTimeline in allTimelines) { trace("Timeline ID:", timeline.id); trace("Linkage:", timeline.linkage); } ``` -------------------------------- ### Control Interactive GAF Animations in Starling Source: https://context7.com/catalystapps/starlinggafplayer/llms.txt This ActionScript snippet demonstrates how to handle touch events on a GAF movie clip and dynamically switch between animation sequences. It includes adding touch event listeners, setting sequences, and managing sequence end events for interactive animation control within Starling. ```actionscript import starling.events.TouchEvent; import starling.events.Touch; import starling.events.TouchPhase; var rocket: GAFMovieClip = mainClip["rocket_instance"]; rocket.setSequence("idle"); ocket.addEventListener(TouchEvent.TOUCH, onRocketTouch); function onRocketTouch(event: TouchEvent): void { var touch: Touch = event.getTouch(this, TouchPhase.BEGAN); if (touch) { var rocket: GAFMovieClip = event.currentTarget as GAFMovieClip; // Switch to explosion sequence rocket.setSequence("explode"); rocket.touchable = false; // Wait for sequence to complete rocket.addEventListener( GAFMovieClip.EVENT_TYPE_SEQUENCE_END, onExplosionComplete ); // Stop parent animation during explosion (rocket.parent as GAFMovieClip).stop(); } } function onExplosionComplete(event: Object): void { var rocket: GAFMovieClip = event.currentTarget as GAFMovieClip; rocket.removeEventListener( GAFMovieClip.EVENT_TYPE_SEQUENCE_END, onExplosionComplete ); // Reset to idle state rocket.setSequence("idle"); rocket.touchable = true; // Resume parent animation (rocket.parent as GAFMovieClip).gotoAndPlay(1); } ``` -------------------------------- ### Manual Video Memory Management for GAF Timelines (ActionScript) Source: https://context7.com/catalystapps/starlinggafplayer/llms.txt This ActionScript snippet illustrates how to manually manage video memory for GAF timelines, allowing you to load and unload textures on demand. This is particularly useful for memory-constrained applications, enabling precise control over which texture atlases are loaded into GPU memory at specific scales and content scale factors. ```actionscript import com.catalystapps.gaf.data.GAFTimeline; var timeline: GAFTimeline = bundle.getGAFTimeline("animations"); // Load specific scale and CSF into GPU memory timeline.loadInVideoMemory( GAFTimeline.CONTENT_SPECIFY, 0.5, // Scale factor 1.0 // Content scale factor ); // Load only default scale/CSF timeline.loadInVideoMemory(GAFTimeline.CONTENT_DEFAULT); // Load all available scales and CSFs timeline.loadInVideoMemory(GAFTimeline.CONTENT_ALL); // Unload from GPU to free memory timeline.unloadFromVideoMemory(GAFTimeline.CONTENT_DEFAULT); // Change scale at runtime timeline.scale = 0.5; timeline.contentScaleFactor = 2.0; // Create movie clip with new settings var movieClip: GAFMovieClip = new GAFMovieClip(timeline); ``` -------------------------------- ### Embed SWF with swfobject Source: https://github.com/catalystapps/starlinggafplayer/blob/master/demo/bundle/bin/index.html Embeds a SWF file into an HTML element using the swfobject JavaScript library. It configures player parameters like menu visibility, scaling, fullscreen, script access, networking, and background color. It also specifies fallback content for users without Flash Player. ```javascript var flashvars = {}; var params = { menu: "false", scale: "noScale", allowFullscreen: "true", allowScriptAccess: "always", allowNetworking: "all", bgcolor: "#FFFFFF", wmode: "direct" }; var attributes = { id: "Demo" }; swfobject.embedSWF("demo.swf", "altContent", "760", "630", "11.6", "expressInstall.swf", flashvars, params, attributes); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.