UNPKG

starling-framework

Version:

A fast, productive library for 2D cross-platform development.

734 lines 153 kB
<!doctype html> <html class="default no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>AssetManager | starling-framework</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="../assets/css/main.css"> </head> <body> <header> <div class="tsd-page-toolbar"> <div class="container"> <div class="table-wrap"> <div class="table-cell" id="tsd-search" data-index="../assets/js/search.js" data-base=".."> <div class="field"> <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label> <input id="tsd-search-field" type="text" /> </div> <ul class="results"> <li class="state loading">Preparing search index...</li> <li class="state failure">The search index is not available</li> </ul> <a href="../index.html" class="title">starling-framework</a> </div> <div class="table-cell" id="tsd-widgets"> <div id="tsd-filter"> <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a> <div class="tsd-filter-group"> <div class="tsd-select" id="tsd-filter-visibility"> <span class="tsd-select-label">All</span> <ul class="tsd-select-list"> <li data-value="public">Public</li> <li data-value="protected">Public/Protected</li> <li data-value="private" class="selected">All</li> </ul> </div> <input type="checkbox" id="tsd-filter-inherited" checked /> <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label> <input type="checkbox" id="tsd-filter-externals" checked /> <label class="tsd-widget" for="tsd-filter-externals">Externals</label> <input type="checkbox" id="tsd-filter-only-exported" /> <label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label> </div> </div> <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a> </div> </div> </div> </div> <div class="tsd-page-title"> <div class="container"> <ul class="tsd-breadcrumb"> <li> <a href="../index.html">starling</a> </li> <li> <a href="../modules/starling.assets.html">assets</a> </li> <li> <a href="starling.assets.assetmanager.html">AssetManager</a> </li> </ul> <h1>Class AssetManager</h1> </div> </div> </header> <div class="container container-main"> <div class="row"> <div class="col-8 col-content"> <section class="tsd-panel tsd-comment"> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The AssetManager handles loading and accessing a variety of asset types. You can add assets directly (via the &#39;add...&#39; methods) or asynchronously via a queue. This allows you to deal with assets in a unified way, no matter if they are loaded from a file, directory, URL, or from an embedded object.</p> </div> <p>The class can deal with the following media types: <ul> <li>Texture, either from Bitmaps or ATF data</li> <li>Texture atlases</li> <li>Bitmap Fonts</li> <li>Sounds</li> <li>XML data</li> <li>JSON data</li> <li>ByteArrays</li> <li>other AssetManagers</li> </ul> </p> <p>For more information on how to add assets from different sources, read the documentation of the &quot;enqueue()&quot; method.</p> <p> <strong>Context Loss</strong></p> <p>When the stage3D context is lost, the AssetManager will automatically restore all loaded textures. To save memory, it will get them from their original sources. Since this is done asynchronously, your images might not reappear all at once, but during a time frame of several seconds. If you want, you can pause your game during that time; the AssetManager dispatches an &quot;Event.TEXTURES_RESTORED&quot; event when all textures have been restored.</p> <p> <strong>Error Handling</strong></p> <p>Loading of some assets may fail while the queue is being processed. In that case, the AssetManager will call the &#39;onError&#39; callback that you can optional provide to the &#39;loadQueue&#39; method. Queue processing will continue after an error, so it&#39;s always guaranteed that the &#39;onComplete&#39; callback is executed, too.</p> <p> <strong>Texture Properties</strong></p> <p>When you enqueue a texture, its properties for &quot;format&quot;, &quot;scale&quot;, &quot;mipMapping&quot;, and &quot;repeat&quot; will reflect the settings of the AssetManager at the time they were enqueued. This means that you can enqueue a bunch of textures, then change the settings and enqueue some more. Like this:</p> <listing> appDir:File = File.applicationDirectory; assets:AssetManager = new AssetManager(); assets.textureOptions.format = Context3DTextureFormat.BGRA; assets.enqueue(appDir.resolvePath(&quot;textures/32bit&quot;)); assets.textureOptions.format = Context3DTextureFormat.BGRA_PACKED; assets.enqueue(appDir.resolvePath(&quot;textures/16bit&quot;)); assets.loadQueue(...);</listing> <p> <strong>Nesting</strong></p> <p>When you enqueue one or more AssetManagers to another one, the &quot;loadQueue&quot; method will oad the Assets of the &quot;child&quot; AssetManager, as well. Later, when accessing assets, the &quot;parent&quot; AssetManager will return the &quot;child&quot; assets as well - just like it returns, say, the SubTextures from a contained TextureAtlas.</p> <p>The main advantage of grouping your assets like this is something else, though: it allows to remove (and dispose) a complete group of assets in one step. The example below loads the assets from two directories. When the contents of one of them are no longer needed, all its assets are removed together.</p> <listing> manager:AssetManager = new AssetManager(); appDir:File = File.applicationDirectory; redAssets:AssetManager = new AssetManager(); manager.enqueueSingle(appDir.resolvePath(&quot;textures/red/&quot;, &quot;redAssets&quot;); greenAssets:AssetManager = new AssetManager(); manager.enqueueSingle(appDir.resolvePath(&quot;textures/green/&quot;, &quot;greenAssets&quot;); manager.loadQueue(...); // loads both &quot;red&quot; and &quot;green&quot; assets // ... later, remove all &quot;red&quot; assets together manager.removeAssetManager(&quot;redAssets&quot;);</listing> <p> <strong>Customization</strong></p> <p>You can customize how assets are created by extending the &#39;AssetFactory&#39; class and registering an instance of your new class at the AssetManager via &#39;registerFactory&#39;. Factories are probed by priority; any factory with a priority &gt; 0 will be executed before the built-in factories.</p> <p>An asset type is identified by a unique String. You can add your own asset types by creating a custom &#39;AssetFactory&#39; and having it add the asset with custom string identifier.</p> <p>By overriding the methods &#39;getNameFromUrl&#39;, &#39;getExtensionFromUrl&#39;, &#39;disposeAsset&#39;, and &#39;log&#39;, you can customize how assets are named and disposed, and you can forward any logging to an external logger. To customize the way data is loaded from URLs or files, you can assign a custom &#39;DataLoader&#39; instance to the AssetManager.</p> <p> @see starling.assets.AssetFactory @see starling.assets.AssetType @see starling.assets.DataLoader</p> </div> </section> <section class="tsd-panel tsd-hierarchy"> <h3>Hierarchy</h3> <ul class="tsd-hierarchy"> <li> <a href="starling.events.eventdispatcher.html" class="tsd-signature-type">EventDispatcher</a> <ul class="tsd-hierarchy"> <li> <span class="target">AssetManager</span> </li> </ul> </li> </ul> </section> <section class="tsd-panel-group tsd-index-group"> <h2>Index</h2> <section class="tsd-panel tsd-index-panel"> <div class="tsd-index-content"> <section class="tsd-index-section tsd-is-external"> <h3>Constructors</h3> <ul class="tsd-index-list"> <li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite tsd-is-external"><a href="starling.assets.assetmanager.html#constructor" class="tsd-kind-icon">constructor</a></li> </ul> </section> <section class="tsd-index-section tsd-is-external"> <h3>Properties</h3> <ul class="tsd-index-list"> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#dataloader" class="tsd-kind-icon">data<wbr>Loader</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#numconnections" class="tsd-kind-icon">num<wbr>Connections</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#numqueuedassets" class="tsd-kind-icon">num<wbr>Queued<wbr>Assets</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#registerbitmapfontswithfontface" class="tsd-kind-icon">register<wbr>Bitmap<wbr>Fonts<wbr>With<wbr>Font<wbr>Face</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#textureoptions" class="tsd-kind-icon">texture<wbr>Options</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#verbose" class="tsd-kind-icon">verbose</a></li> </ul> </section> <section class="tsd-index-section tsd-is-external"> <h3>Methods</h3> <ul class="tsd-index-list"> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#addasset" class="tsd-kind-icon">add<wbr>Asset</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="starling.assets.assetmanager.html#addeventlistener" class="tsd-kind-icon">add<wbr>Event<wbr>Listener</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="starling.assets.assetmanager.html#dispatchevent" class="tsd-kind-icon">dispatch<wbr>Event</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="starling.assets.assetmanager.html#dispatcheventwith" class="tsd-kind-icon">dispatch<wbr>Event<wbr>With</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#dispose" class="tsd-kind-icon">dispose</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#enqueue" class="tsd-kind-icon">enqueue</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#enqueuesingle" class="tsd-kind-icon">enqueue<wbr>Single</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getasset" class="tsd-kind-icon">get<wbr>Asset</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getassetmanager" class="tsd-kind-icon">get<wbr>Asset<wbr>Manager</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getassetmanagernames" class="tsd-kind-icon">get<wbr>Asset<wbr>Manager<wbr>Names</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getassetnames" class="tsd-kind-icon">get<wbr>Asset<wbr>Names</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getbitmapfont" class="tsd-kind-icon">get<wbr>Bitmap<wbr>Font</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getbitmapfontnames" class="tsd-kind-icon">get<wbr>Bitmap<wbr>Font<wbr>Names</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getbytearray" class="tsd-kind-icon">get<wbr>Byte<wbr>Array</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getbytearraynames" class="tsd-kind-icon">get<wbr>Byte<wbr>Array<wbr>Names</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getobject" class="tsd-kind-icon">get<wbr>Object</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getobjectnames" class="tsd-kind-icon">get<wbr>Object<wbr>Names</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getsound" class="tsd-kind-icon">get<wbr>Sound</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getsoundnames" class="tsd-kind-icon">get<wbr>Sound<wbr>Names</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#gettexture" class="tsd-kind-icon">get<wbr>Texture</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#gettextureatlas" class="tsd-kind-icon">get<wbr>Texture<wbr>Atlas</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#gettextureatlasnames" class="tsd-kind-icon">get<wbr>Texture<wbr>Atlas<wbr>Names</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#gettexturenames" class="tsd-kind-icon">get<wbr>Texture<wbr>Names</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#gettextures" class="tsd-kind-icon">get<wbr>Textures</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getxml" class="tsd-kind-icon">get<wbr>Xml</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#getxmlnames" class="tsd-kind-icon">get<wbr>Xml<wbr>Names</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.assets.assetmanager.html#get_dataloader" class="tsd-kind-icon">get_<wbr>data<wbr>Loader</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.assets.assetmanager.html#get_numconnections" class="tsd-kind-icon">get_<wbr>num<wbr>Connections</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.assets.assetmanager.html#get_numqueuedassets" class="tsd-kind-icon">get_<wbr>num<wbr>Queued<wbr>Assets</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.assets.assetmanager.html#get_registerbitmapfontswithfontface" class="tsd-kind-icon">get_<wbr>register<wbr>Bitmap<wbr>Fonts<wbr>With<wbr>Font<wbr>Face</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.assets.assetmanager.html#get_textureoptions" class="tsd-kind-icon">get_<wbr>texture<wbr>Options</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.assets.assetmanager.html#get_verbose" class="tsd-kind-icon">get_<wbr>verbose</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="starling.assets.assetmanager.html#haseventlistener" class="tsd-kind-icon">has<wbr>Event<wbr>Listener</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#loadqueue" class="tsd-kind-icon">load<wbr>Queue</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#playsound" class="tsd-kind-icon">play<wbr>Sound</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#purge" class="tsd-kind-icon">purge</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#purgequeue" class="tsd-kind-icon">purge<wbr>Queue</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#registerfactory" class="tsd-kind-icon">register<wbr>Factory</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#removeasset" class="tsd-kind-icon">remove<wbr>Asset</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#removeassetmanager" class="tsd-kind-icon">remove<wbr>Asset<wbr>Manager</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#removebitmapfont" class="tsd-kind-icon">remove<wbr>Bitmap<wbr>Font</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#removebytearray" class="tsd-kind-icon">remove<wbr>Byte<wbr>Array</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="starling.assets.assetmanager.html#removeeventlistener" class="tsd-kind-icon">remove<wbr>Event<wbr>Listener</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="starling.assets.assetmanager.html#removeeventlisteners" class="tsd-kind-icon">remove<wbr>Event<wbr>Listeners</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#removeobject" class="tsd-kind-icon">remove<wbr>Object</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#removesound" class="tsd-kind-icon">remove<wbr>Sound</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#removetexture" class="tsd-kind-icon">remove<wbr>Texture</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#removetextureatlas" class="tsd-kind-icon">remove<wbr>Texture<wbr>Atlas</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="starling.assets.assetmanager.html#removexml" class="tsd-kind-icon">remove<wbr>Xml</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.assets.assetmanager.html#set_dataloader" class="tsd-kind-icon">set_<wbr>data<wbr>Loader</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.assets.assetmanager.html#set_numconnections" class="tsd-kind-icon">set_<wbr>num<wbr>Connections</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.assets.assetmanager.html#set_registerbitmapfontswithfontface" class="tsd-kind-icon">set_<wbr>register<wbr>Bitmap<wbr>Fonts<wbr>With<wbr>Font<wbr>Face</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.assets.assetmanager.html#set_textureoptions" class="tsd-kind-icon">set_<wbr>texture<wbr>Options</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected tsd-is-external"><a href="starling.assets.assetmanager.html#set_verbose" class="tsd-kind-icon">set_<wbr>verbose</a></li> </ul> </section> </div> </section> </section> <section class="tsd-panel-group tsd-member-group tsd-is-external"> <h2>Constructors</h2> <section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite tsd-is-external"> <a name="constructor" class="tsd-anchor"></a> <h3>constructor</h3> <ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite tsd-is-external"> <li class="tsd-signature tsd-kind-icon">new <wbr>Asset<wbr>Manager<span class="tsd-signature-symbol">(</span>scaleFactor<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="starling.assets.assetmanager.html" class="tsd-signature-type">AssetManager</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <p>Overrides <a href="starling.events.eventdispatcher.html">EventDispatcher</a>.<a href="starling.events.eventdispatcher.html#constructor">constructor</a></p> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L134">lib/starling/assets/AssetManager.d.ts:134</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Create a new instance with the given scale factor.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> scaleFactor: <span class="tsd-signature-type">number</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="starling.assets.assetmanager.html" class="tsd-signature-type">AssetManager</a></h4> </li> </ul> </section> </section> <section class="tsd-panel-group tsd-member-group tsd-is-external"> <h2>Properties</h2> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="dataloader" class="tsd-anchor"></a> <h3>data<wbr>Loader</h3> <div class="tsd-signature tsd-kind-icon">data<wbr>Loader<span class="tsd-signature-symbol">:</span> <a href="starling.assets.dataloader.html" class="tsd-signature-type">DataLoader</a></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L371">lib/starling/assets/AssetManager.d.ts:371</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The DataLoader is used to load any data from files or URLs. If you need to customize its behavior (e.g. to add a caching mechanism), assign your custom instance here.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="numconnections" class="tsd-anchor"></a> <h3>num<wbr>Connections</h3> <div class="tsd-signature tsd-kind-icon">num<wbr>Connections<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L359">lib/starling/assets/AssetManager.d.ts:359</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The maximum number of parallel connections that are spawned when loading the queue. More connections can reduce loading times, but require more memory. @default 3.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="numqueuedassets" class="tsd-anchor"></a> <h3>num<wbr>Queued<wbr>Assets</h3> <div class="tsd-signature tsd-kind-icon">num<wbr>Queued<wbr>Assets<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L354">lib/starling/assets/AssetManager.d.ts:354</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns the number of raw assets that have been enqueued, but not yet loaded.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="registerbitmapfontswithfontface" class="tsd-anchor"></a> <h3>register<wbr>Bitmap<wbr>Fonts<wbr>With<wbr>Font<wbr>Face</h3> <div class="tsd-signature tsd-kind-icon">register<wbr>Bitmap<wbr>Fonts<wbr>With<wbr>Font<wbr>Face<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L378">lib/starling/assets/AssetManager.d.ts:378</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Indicates if bitmap fonts should be registered with their &quot;face&quot; attribute from the font XML file. Per default, they are registered with the name of the texture file. @default false</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="textureoptions" class="tsd-anchor"></a> <h3>texture<wbr>Options</h3> <div class="tsd-signature tsd-kind-icon">texture<wbr>Options<span class="tsd-signature-symbol">:</span> <a href="starling.textures.textureoptions.html" class="tsd-signature-type">TextureOptions</a></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L365">lib/starling/assets/AssetManager.d.ts:365</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Textures will be created with the options set up in this object at the time of enqueuing.</p> </div> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external"> <a name="verbose" class="tsd-anchor"></a> <h3>verbose</h3> <div class="tsd-signature tsd-kind-icon">verbose<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L349">lib/starling/assets/AssetManager.d.ts:349</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>When activated, the class will trace information about added/enqueued assets. @default true</p> </div> </div> </section> </section> <section class="tsd-panel-group tsd-member-group tsd-is-external"> <h2>Methods</h2> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="addasset" class="tsd-anchor"></a> <h3>add<wbr>Asset</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">add<wbr>Asset<span class="tsd-signature-symbol">(</span>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, asset<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, type<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L227">lib/starling/assets/AssetManager.d.ts:227</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Add an asset with a certain name and type.</p> </div> <p>Beware: if the slot (name + type) was already taken, the existing object will be disposed and replaced by the new one.</p> <p> @param name The name with which the asset can be retrieved later. Must be unique within this asset type. @param asset The actual asset to add (e.g. a texture, a sound, etc). @param type The type of the asset. If omitted, the type will be determined automatically (which works for all standard types defined within the &#39;AssetType&#39; class).</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>name: <span class="tsd-signature-type">string</span></h5> </li> <li> <h5>asset: <span class="tsd-signature-type">any</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> type: <span class="tsd-signature-type">string</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> <a name="addeventlistener" class="tsd-anchor"></a> <h3>add<wbr>Event<wbr>Listener</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> <li class="tsd-signature tsd-kind-icon">add<wbr>Event<wbr>Listener<span class="tsd-signature-symbol">(</span>type<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, listener<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Function</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <p>Inherited from <a href="starling.events.eventdispatcher.html">EventDispatcher</a>.<a href="starling.events.eventdispatcher.html#addeventlistener">addEventListener</a></p> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/events/EventDispatcher.d.ts#L32">lib/starling/events/EventDispatcher.d.ts:32</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Registers an event listener at a certain object.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>type: <span class="tsd-signature-type">string</span></h5> </li> <li> <h5>listener: <span class="tsd-signature-type">Function</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> <a name="dispatchevent" class="tsd-anchor"></a> <h3>dispatch<wbr>Event</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> <li class="tsd-signature tsd-kind-icon">dispatch<wbr>Event<span class="tsd-signature-symbol">(</span>event<span class="tsd-signature-symbol">: </span><a href="starling.events.event.html" class="tsd-signature-type">Event</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <p>Inherited from <a href="starling.events.eventdispatcher.html">EventDispatcher</a>.<a href="starling.events.eventdispatcher.html#dispatchevent">dispatchEvent</a></p> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/events/EventDispatcher.d.ts#L45">lib/starling/events/EventDispatcher.d.ts:45</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Dispatches an event to all objects that have registered listeners for its type. If an event with enabled &#39;bubble&#39; property is dispatched to a display object, it will travel up along the line of parents, until it either hits the root object or someone stops its propagation manually.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>event: <a href="starling.events.event.html" class="tsd-signature-type">Event</a></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> <a name="dispatcheventwith" class="tsd-anchor"></a> <h3>dispatch<wbr>Event<wbr>With</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> <li class="tsd-signature tsd-kind-icon">dispatch<wbr>Event<wbr>With<span class="tsd-signature-symbol">(</span>type<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, bubbles<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span>, data<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <p>Inherited from <a href="starling.events.eventdispatcher.html">EventDispatcher</a>.<a href="starling.events.eventdispatcher.html#dispatcheventwith">dispatchEventWith</a></p> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/events/EventDispatcher.d.ts#L50">lib/starling/events/EventDispatcher.d.ts:50</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Dispatches an event with the given parameters to all objects that have registered listeners for the given type. The method uses an internal pool of event objects to avoid allocations.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>type: <span class="tsd-signature-type">string</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> bubbles: <span class="tsd-signature-type">boolean</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> data: <span class="tsd-signature-type">any</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="dispose" class="tsd-anchor"></a> <h3>dispose</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">dispose<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L144">lib/starling/assets/AssetManager.d.ts:144</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Disposes all assets and purges the queue.</p> </div> <p>Beware that all references to the assets will remain intact, even though the assets are no longer valid. Call &#39;purge&#39; if you want to remove all resources and reuse the AssetManager later.</p> </div> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="enqueue" class="tsd-anchor"></a> <h3>enqueue</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">enqueue<span class="tsd-signature-symbol">(</span>assets<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Array</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L178">lib/starling/assets/AssetManager.d.ts:178</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Enqueues one or more raw assets; they will only be available after successfully executing the &quot;loadQueue&quot; method. This method accepts a variety of different objects:</p> </div> <ul> <li>Strings or URLRequests containing an URL to a local or remote resource. Supported types: <code>png, jpg, gif, atf, mp3, xml, fnt, json, binary</code>.</li> <li>Instances of the File class (AIR only) pointing to a directory or a file. Directories will be scanned recursively for all supported types.</li> <li>Classes that contain <code>static</code> embedded assets.</li> <li>If the file extension is not recognized, the data is analyzed to see if contains XML or JSON data. If it&#39;s neither, it is stored as ByteArray.</li> </ul> <p>Suitable object names are extracted automatically: A file named &quot;image.png&quot; will be accessible under the name &quot;image&quot;. When enqueuing embedded assets via a class, the variable name of the embedded object will be used as its name. An exception are texture atlases: they will have the same name as the actual texture they are referencing.</p> <p>XMLs are made available via &quot;getXml()&quot;; this includes XMLs containing texture atlases or bitmap fonts, which are processed along the way. Bitmap fonts are also registered at the TextField class.</p> <p>If you pass in JSON data, it will be parsed into an object and will be available via &quot;getObject()&quot;.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>assets: <span class="tsd-signature-type">Array</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="enqueuesingle" class="tsd-anchor"></a> <h3>enqueue<wbr>Single</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">enqueue<wbr>Single<span class="tsd-signature-symbol">(</span>asset<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, name<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, options<span class="tsd-signature-symbol">?: </span><a href="starling.textures.textureoptions.html" class="tsd-signature-type">TextureOptions</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L190">lib/starling/assets/AssetManager.d.ts:190</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Enqueues a single asset with a custom name that can be used to access it later. If the asset is a texture, you can also add custom texture options.</p> </div> <p> @param asset The asset that will be enqueued; accepts the same objects as the &#39;enqueue&#39; method. @param name The name under which the asset will be found later. If you pass null or omit the parameter, it&#39;s attempted to generate a name automatically. @param options Custom options that will be used if &#39;asset&#39; points to texture data. @return the name with which the asset was registered.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>asset: <span class="tsd-signature-type">any</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> name: <span class="tsd-signature-type">string</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> options: <a href="starling.textures.textureoptions.html" class="tsd-signature-type">TextureOptions</a></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="getasset" class="tsd-anchor"></a> <h3>get<wbr>Asset</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">get<wbr>Asset<span class="tsd-signature-symbol">(</span>type<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, recursive<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L235">lib/starling/assets/AssetManager.d.ts:235</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Retrieves an asset of the given type, with the given name. If &#39;recursive&#39; is true, the method will traverse included texture atlases and asset managers.</p> </div> <p>Typically, you will use one of the type-safe convenience methods instead, like &#39;getTexture&#39;, &#39;getSound&#39;, etc.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>type: <span class="tsd-signature-type">string</span></h5> </li> <li> <h5>name: <span class="tsd-signature-type">string</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> recursive: <span class="tsd-signature-type">boolean</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="getassetmanager" class="tsd-anchor"></a> <h3>get<wbr>Asset<wbr>Manager</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">get<wbr>Asset<wbr>Manager<span class="tsd-signature-symbol">(</span>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="starling.assets.assetmanager.html" class="tsd-signature-type">AssetManager</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L308">lib/starling/assets/AssetManager.d.ts:308</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns an asset manager with a certain name, or null if it&#39;s not found.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>name: <span class="tsd-signature-type">string</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="starling.assets.assetmanager.html" class="tsd-signature-type">AssetManager</a></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external"> <a name="getassetmanagernames" class="tsd-anchor"></a> <h3>get<wbr>Asset<wbr>Manager<wbr>Names</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external"> <li class="tsd-signature tsd-kind-icon">get<wbr>Asset<wbr>Manager<wbr>Names<span class="tsd-signature-symbol">(</span>prefix<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, out<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Vector</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Vector</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">&gt;</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/openfl/starling/blob/bce2af2/lib/starling/assets/AssetManager.d.ts#L312">lib/starling/assets/AssetManager.d.ts:312</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns all asset manager names that start with a certain string, sorted alphabetically. If you pass an <code>out</code>-vector, the names will be added to that vector.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> prefix: <span class="tsd-signature-type">string</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> out: <span class="tsd-signature-type">Vector</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">&gt;</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Vector</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-