{"id":13744421,"url":"https://github.com/krechagames/assets-management","last_synced_at":"2025-05-09T03:31:42.149Z","repository":{"id":150204186,"uuid":"9518891","full_name":"krechagames/assets-management","owner":"krechagames","description":"Load and store assets (also for Starling)","archived":false,"fork":false,"pushed_at":"2013-07-29T12:42:00.000Z","size":4398,"stargazers_count":18,"open_issues_count":0,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-04T05:04:12.258Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"ActionScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krechagames.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-18T10:14:47.000Z","updated_at":"2024-02-09T21:43:34.000Z","dependencies_parsed_at":"2023-04-03T17:01:18.240Z","dependency_job_id":null,"html_url":"https://github.com/krechagames/assets-management","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krechagames%2Fassets-management","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krechagames%2Fassets-management/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krechagames%2Fassets-management/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krechagames%2Fassets-management/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krechagames","download_url":"https://codeload.github.com/krechagames/assets-management/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224810993,"owners_count":17373898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T05:01:09.138Z","updated_at":"2024-11-15T16:30:54.355Z","avatar_url":"https://github.com/krechagames.png","language":"ActionScript","funding_links":[],"categories":["Video Games"],"sub_categories":["Game Engine"],"readme":"assets-management\n=================\nLoad and store assets (also for Starling). Manager assets in your project. Load and store any type of asset, prepare loaded file to use in IAssetsStorage class (create own storage like StarlingStorage).\n\nFull description and manual here:\nhttp://blog.krecha-games.com/assets-management/\n\nexample (native flash)\n======================\nThis is the most simpliest use of AssetsManager. In this example we use external assets manifest assets.xml (below) to describe which file you want to load and what type are they.\n\n```actionscript\n//storage assets\nvar storage:IAssetsStorage = new AssetsStorage();\n\n//load assets\nvar loader:AssetsLoader = new AssetsLoader(storage);\nloader.addEventListener(Event.COMPLETE, loadAssetsCompleteHandler, false, 0, true);\n\n//(optional) load assets.xml with assets manifest\nvar config:AssetsConfig = new AssetsConfig(\"config\", \"./assets/assets.xml\", null);\nconfig.addEventListener(Event.COMPLETE, loadConfigCompleteHandler, false, 0, true);\nconfig.load();\n\n//1. Load assets.xml complete, load assets from manifest\nfunction loadConfigCompleteHandler(event:Event):void {\n  loadAssets(config.list);\n}\n\n//2. Load assets list. List can be pass manually or load from assets.xml\nfunction loadAssets(list:Vector.\u003cIAsset\u003e):void {\n  loader.load(list);\n}\n\n//3. Load assets complete, do whatever you want to do with. AssetsLoader's job is done!\nfunction loadAssetsCompleteHandler(event:Event):void {\n\tvar bg:Bitmap = ImageAsset(storage.getAsset(\"bg\")).castBitmap;\n\n\tvar logotype:Bitmap = ImageAsset(storage.getAsset(\"logotype\")).castBitmap;\n\n\tvar music:Sound = SoundAsset(storage.getAsset(\"music\")).castSound;\n}\n\n//Dispose all objects\nfunction dispose():void {\n\tconfig.dispose();\n\tconfig.removeEventListener(Event.COMPLETE, loadConfigCompleteHandler);\n\tconfig = null;\n\n\tloader.removeEventListener(Event.COMPLETE, loadAssetsCompleteHandler);\n\tloader = null;\n\n\tstorage.dispose();\n\tstorage = null;\n}\n```\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\" ?\u003e\n\u003cdata\u003e\n    \u003cgroup name=\"common\"\u003e\n        \u003casset id=\"db\" url=\"assets/data/db.csv\" type=\"text\" /\u003e\n        \u003casset id=\"lang\" url=\"assets/data/lang.xml\" type=\"text\" /\u003e\n        \u003casset id=\"music\" url=\"assets/sounds/music.mp3\" type=\"sound\" /\u003e\n    \u003c/group\u003e\n\n    \u003cgroup name=\"x1\"\u003e\n        \u003casset id=\"bg\" url=\"assets/textures/bg@x1.jpg\" type=\"image\" /\u003e\n        \u003casset id=\"logotype\" url=\"assets/textures/logotype@x1.jpg\" type=\"image\" /\u003e\n\n        \u003casset id=\"atlas\" url=\"assets/textures/atlas@x1.png\" type=\"image\" /\u003e\n        \u003casset id=\"atlas_xml\" url=\"assets/textures/atlas@x1.xml\" type=\"text\" /\u003e\n\n        \u003casset id=\"compressed_texture\" url=\"assets/textures/compressed_texture@x1.atf\" type=\"raw\" /\u003e\n    \u003c/group\u003e\n\n    \u003cgroup name=\"x2\"\u003e\n        \u003casset id=\"bg\" url=\"assets/textures/bg@x2.jpg\" type=\"image\" /\u003e\n        \u003casset id=\"logotype\" url=\"assets/textures/logotype@x2.jpg\" type=\"image\" /\u003e\n\n        \u003casset id=\"atlas\" url=\"assets/textures/atlas@x2.png\" type=\"image\" /\u003e\n        \u003casset id=\"atlas_xml\" url=\"assets/textures/atlas@x2.xml\" type=\"text\" /\u003e\n\n        \u003casset id=\"compressed_texture\" url=\"assets/textures/compressed_texture@x2.atf\" type=\"raw\" /\u003e\n    \u003c/group\u003e\n\u003c/data\u003e\n```\n\nexample (Starling)\n==================\nYou can use any type of assets storage! Just what you need is to create class that implements IAssetsStorage (or extends AssetsStorage class which is the basic implementation of IAssetsStorage). Example of this approach is StarlingStorage class. Features of this storage is few new methods which prepering textures to use. More info here: http://bit.ly/11l7Ul2\n\nPrepare loader and config like in above example:\n```actionscript\n//storage assets\nvar storage:StarlingStorage = new StarlingStorage();\n\n//load assets\nvar loader:AssetsLoader = new AssetsLoader(storage);\nloader.addEventListener(Event.COMPLETE, loadAssetsCompleteHandler, false, 0, true);\nloader.load(Vector.\u003cIAsset\u003e([ /* assets from manifest or pass manually */  ]));\n\n//3a. Load assets complete, do whatever you want to do with. AssetsLoader's job is done!\nfunction loadAssetsCompleteHandler(event:Event):void {\n  var img:Image = new Image(storage.getTexture(\"atlasName\", \"textureName\"));\n\n  var tf:TextField = new TextField(100, 100, \"text\", storage.getBitmapFont(\"fontName\"));\n\n  var sound:SoundAsset = SoundAsset(storage.getAsset(\"music\")).castSound;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrechagames%2Fassets-management","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrechagames%2Fassets-management","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrechagames%2Fassets-management/lists"}