I am writing a project which is using too few asset. I would like to know what is happening under the hood of AssetManager.
First of all as far I inspected to source code and understand by tutorial and docs; AssetManager is a manager that handling variety of asset types, their loading status (events etc.), holding them in a dictionary and acting as a getter & setter.
Since I am not using too much asset I am thinking about defining my own simple assetmanager class that is keeping all embed asset class definitions together. Which is means I won't have a progress informer event (like using for loading bars).
First question is: is there a performance & loading time difference between using assetmanager or using simpler class like that ?
Second question is: When same asset used multiple times like following, which is optimal way or are they really making any difference ? Also embed asset means it is being loaded to memory since beginning right ? Also compiling several image into an atlas is better while using embed assets too ?
Method 1 - These 3 instance of images using same memory adressed texture right ?
[Embed(source="assets/sample.png")] public static const samplePointer:Class; // get embed file(AIR & Web-Based Compatible) var sampleTexture:Texture = Texture.fromEmbeddedAsset(samplePointer); var sampleUsed1:Image = new Image(sampleTexture); var sampleUsed2:Image = new Image(sampleTexture); var sampleUsed3:Image = new Image(sampleTexture); addChild(sampleUsed1); addChild(sampleUsed2); addChild(sampleUsed3);
Method 2 - Is it using more memory than first method in terms of loading method of related texture ?:
// enqueue a file from disk (AIR only) var appDir:File = File.applicationDirectory; var assets:AssetManager = new AssetManager(); assets.enqueue(appDir.resolvePath("assets/sample.png")); //Let's assume we call rest after enqueue completed var sampleTexture:Texture = assets.getTexture("sample"); var sampleUsed1:Image = new Image(sampleTexture); var sampleUsed2:Image = new Image(sampleTexture); var sampleUsed3:Image = new Image(sampleTexture); addChild(sampleUsed1); addChild(sampleUsed2); addChild(sampleUsed3);