{"id":13745042,"url":"https://github.com/colorhook/as-spring","last_synced_at":"2025-05-09T04:33:21.436Z","repository":{"id":138552615,"uuid":"1945869","full_name":"colorhook/as-spring","owner":"colorhook","description":"ActionScript IOC framework","archived":false,"fork":false,"pushed_at":"2013-01-22T14:28:04.000Z","size":244,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-04T05:05:34.840Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/colorhook.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-06-24T04:43:47.000Z","updated_at":"2024-01-26T05:08:10.000Z","dependencies_parsed_at":"2023-03-11T21:00:55.978Z","dependency_job_id":null,"html_url":"https://github.com/colorhook/as-spring","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/colorhook%2Fas-spring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colorhook%2Fas-spring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colorhook%2Fas-spring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colorhook%2Fas-spring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colorhook","download_url":"https://codeload.github.com/colorhook/as-spring/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224819761,"owners_count":17375322,"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:21.077Z","updated_at":"2024-11-15T17:31:07.298Z","avatar_url":"https://github.com/colorhook.png","language":"ActionScript","readme":"as-spring: ActionScript IOC framework\n=====================================\n\nas-spring is an ActionScript IOC framework, used to define and use dynamic objects without re-compile the source code.\n\nExample\n--------------\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cspring-config\u003e\n\t\u003cbeans\u003e\n\t\t\u003cbean id=\"textFieldBean\" class=\"flash.text.TextField\"\u003e\n\n\t\t\t\u003cproperty name=\"text\" value=\"Hello World\"/\u003e\n\t\t\t\u003cproperty name=\"width\" value=\"300\"/\u003e\n\t\t\t\u003cproperty name=\"x\" value=\"160\"/\u003e\n\t\t\t\u003cproperty name=\"y\" value=\"100\"/\u003e\n\n\t\t\t\u003cmethod name=\"setTextFormat\"\u003e\n\t\t\t\t\u003cmethod-arg\u003e\n\t\t\t\t\t\u003cbean class=\"flash.text.TextFormat\"\u003e\n\t\t\t\t\t\t\u003cproperty name=\"color\" value=\"0x003366\"/\u003e\n\t\t\t\t\t\t\u003cproperty name=\"bold\" value=\"true\"/\u003e\n\t\t\t\t\t\t\u003cproperty name=\"size\" value=\"36\"/\u003e\n\t\t\t\t\t\u003c/bean\u003e\n\t\t\t\t\u003c/method-arg\u003e\n\t\t\t\u003c/method\u003e\n\n\t\t\u003c/bean\u003e\n\t\u003c/beans\u003e\n\u003c/spring-config\u003e\n```\n\n```as\nimport com.colorhook.spring.context.ContextLoader;\n\nvar contextLoader:ContextLoader = new ContextLoader();\ncontextLoader.addEventListener(Event.COMPLETE, onContextLoaderComplete);\ncontextLoader.load(\"as-spring.xml\");\n\nfunction onContextLoaderComplete(e){\n\tcontextLoader.removeEventListener(Event.COMPLETE, onContextLoaderComplete);\n\tvar bean:* = contextLoader.contextInfo.getBean(\"textFieldBean\");\n}\n```\n\nelement bean\n--------------\nelement bean是最简单也是最基础的bean，它代表最基本的数据结构\n\n```xml\n...\n\u003celement id='num' value='200' type='int'/\u003e\n\u003celement id='num2' value='200' type='uint'/\u003e\n\u003celement id='num3' value='200' type='Number'/\u003e\n\u003celement id='str'\u003e\u003cvalue\u003estring type data\u003c/value\u003e\u003c/element\u003e\n\u003celement id='arr'\u003e\u003cvalue\u003e[1,2,3,4]\u003c/value\u003e\u003c/element\u003e\n\u003celement id='bool'\u003e\u003cvalue\u003etrue\u003c/value\u003e\u003c/element\u003e\n...\n```\n\nlist bean\n--------------\nlist bean是一个数组对象，用于存放数组结构的数据\n\n```xml\n...\n\u003clist id='myList'\u003e\n  \u003celement value='1' type='int'/\u003e\n  \u003celement value='2'/\u003e\n  \u003celement value='false' type='Boolean'/\u003e\n  \u003clist\u003e\n  \t\u003celement value='4'/\u003e\n  \t\u003celement value='5'/\u003e\n  \u003c/list\u003e\n\u003c/list\u003e\n...\n```\n\n```as\nvar list:Array = contextInfo.getBean('myList') as Array;\ntrace(list); // [1, '2', false, ['4', '5']]\n```\n\nmap bean\n--------------\nmap bean是一个Hash对象，用于存放键值对结构的数据\n\n```xml\n...\n\u003cmap id='myMap'\u003e\n  \u003ckey name='name' value='as-spring'\u003e\n  \u003ckey name='version'\u003e2.x\u003c/key\u003e\n  \u003ckey name='info'\u003e\n  \t\u003cmap\u003e\n  \t\t\u003ckey name='contributors'\u003e\n\t\t\t\u003clist\u003e\n\t\t\t\u003c/list\u003e\n\t\t\u003c/key\u003e\n  \t\t\u003ckey name='github'\u003e\n\t\t\t\u003cvalue\u003ehttp://github.com/colorhook/as-spring\u003c/value\u003e\n\t\t\u003c/key\u003e\n  \t\u003c/map\u003e\n  \u003c/key\u003e\n\u003c/map\u003e\n...\n```\n\n```as\nvar map:* = contextInfo.getBean('myMap');\ntrace(map); // {name: 'as-spring', version: '2.x', \n\t\t\t//  info: {contributors: [], github:'http://github.com/colorhook/as-spring'}}\n```\n\nsingleton bean\n--------------\nbean可以是singleton类型的，即一个bean只会有单一实例\n\n```xml\n...\n\u003cbean id='sprite' type='flash.display.Sprite' singleton='true'\u003e\n\u003c/bean\u003e\n...\n```\n\n```as\nvar s1:Sprite = contextInfo.getBean('sprite') as Sprite;\nvar s2:Sprite = contextInfo.getBean('sprite') as Sprite;\ntrace(s1 === s2); //true\n```\n\nfactory bean\n--------------\nfactory bean表示一个bean不是通过new关键字创建的，而是通过工厂方法创建的\n\n```as\npackage{\n\tpublic class Factory{\n\n\t\tpublic static function getObject():*{\n\t\t\treturn xxx;\n\t\t}\n\t}\n}\n```\n\n```xml\n...\n\u003cbean id='obj' class='Factory' factory-method='getObject'\u003e\n\u003c/bean\u003e\n...\n```\n\n```as\nvar obj:* = contextInfo.getBean('obj');\n```\n\n通过swf文件反射bean\n--------------\n可以在一个SWF文件中输出class，然后在另一个SWF中通过bean的方式加载使用这个class\n\n```xml\n...\n\u003cclasses\u003e\n\t\u003cclass name='app.MyClass' lib='app.MyClass.swf'/\u003e\n\u003c/classes\u003e\n\u003cbeans\u003e\n\t\u003cbean id='app' class='app.MyClass'/\u003e\n\u003c/beans\u003e\n...\n```\n\n```as\nvar app:* = contextInfo.getBean('app');\n```\n\n\nAPI Reference\n--------------\n[http://colorhook.github.com/as-spring/]\n\nLicence\n--------------\nas-spring is free to use under MIT license. \n\n\tCopyright (c) 2010-2011 as-spring Authors. All rights reserved.\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\nBugs \u0026 Feedback\n----------------\n\nPlease feel free to report bugs or feature requests.\nYou can send me private message on `github`, or send me an email to: [colorhook@gmail.com]\n\n\n\n","funding_links":[],"categories":["Unsorted"],"sub_categories":["Other API"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolorhook%2Fas-spring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolorhook%2Fas-spring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolorhook%2Fas-spring/lists"}