{"id":13744588,"url":"https://github.com/SimonRichardson/as3-mixins","last_synced_at":"2025-05-09T03:32:31.647Z","repository":{"id":66364242,"uuid":"1630344","full_name":"SimonRichardson/as3-mixins","owner":"SimonRichardson","description":"Create real mixins using bytecode injection at runtime.","archived":true,"fork":false,"pushed_at":"2011-09-15T14:58:27.000Z","size":1884,"stargazers_count":28,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-15T16:40:58.594Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.simonrichardson.info","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/SimonRichardson.png","metadata":{"files":{"readme":"README.textile","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-04-18T12:37:21.000Z","updated_at":"2023-01-28T21:31:58.000Z","dependencies_parsed_at":"2023-02-20T03:00:26.505Z","dependency_job_id":null,"html_url":"https://github.com/SimonRichardson/as3-mixins","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonRichardson%2Fas3-mixins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonRichardson%2Fas3-mixins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonRichardson%2Fas3-mixins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonRichardson%2Fas3-mixins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SimonRichardson","download_url":"https://codeload.github.com/SimonRichardson/as3-mixins/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253183217,"owners_count":21867382,"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:12.285Z","updated_at":"2025-05-09T03:32:30.998Z","avatar_url":"https://github.com/SimonRichardson.png","language":"ActionScript","funding_links":[],"categories":["Utilities"],"sub_categories":["Dependency Injection"],"readme":"h1. AS3-Mixins\n\nAS3-Mixin is a project to enable runtime bytecode generation of mixins. The project uses a strict\ntyped setup to mix the interfaces (known as definitions) and concrete classes (known as \nimplementations). \n\nAS3-Mixin uses the \"MIT\":http://en.wikipedia.org/wiki/MIT_License license.\n\nh2. Performance\n\nTo enable AS3-Mixin to work we have to create a series of SWF's at runtime which will then be \ninjected into your application SWF. This obviously has a hit when creating the application, but\nonce the implementation has been created, it is relatively performance free to create new \ninstances of the implementation (relatively meaning that it has to delegate the creation of the\ninstance and will be slower than instantiating it by hand).\n\nh2. Thanks\n\nThe inspiration for this was \"AS3-retrofit\":https://github.com/brianheylin/as3-retrofit, although\nI've removed quite a lot from that. Also there are subtle changes through out, but there could\nbe a time where I move this back to AS3-retrofit, although I think AS3-Mixins sounds better.\n\nAS3-Mixin uses \n* \"AS3-Signals\":https://github.com/robertpenner/as3-signals\n* \"FLemit\":http://code.google.com/p/flemit/\n* \"ASunit\":https://github.com/patternpark/asunit\n\nh2. Example\n\nTo create a AS3-Mixin you have to define a series of definitions and implementations.\n\nCreate a definition IPosition.as in this case it's just an interface.\n\u003cpre\u003e\u003ccode\u003e\npackage org.osflash.mixins.support\n{\n    public interface IPosition\n    {\n        \n        function get x() : int;\n        \n        function set x(value : int) : void;\n        \n        function get y() : int;\n        \n        function set y(value : int) : void;\n    }\n}\n\u003c/code\u003e\u003c/pre\u003e\n\nCreate a implementation PositionImpl.as.\n\u003cpre\u003e\u003ccode\u003e\npackage org.osflash.mixins.support.impl\n{\n    import org.osflash.mixins.support.IPosition;\n    \n    public final class PositionImpl implements IPosition\n    {\n        \n        private var _x : int;\n        \n        private var _y : int;\n\n        public function PositionImpl()\n        {\n            _x = 0;\n            _y = 0;\n        }\n        \n        public function get x() : int {    return _x; }\n\n        public function set x(value : int) : void {    _x = value;    }\n\n        public function get y() : int {    return _y; }\n\n        public function set y(value : int) : void {    _y = value;    }\n    }\n}\n\u003c/code\u003e\u003c/pre\u003e\n\nThen finally make the definitive implementation that's going to hold your mixin together (note:\nI've also added a ISize definition and SizeImpl to make it a true mixin).\n\u003cpre\u003e\u003ccode\u003e\npackage org.osflash.mixins.support\n{\n    public interface ISquare extends ISize, IPosition\n    {\n    }\n}\n\u003c/code\u003e\u003c/pre\u003e\n\nThen to sew it altogether:\n\u003cpre\u003e\u003ccode\u003e\nvar mixin : IMixin = new Mixin();\nmixin.add(IPosition, PositionImpl);\nmixin.add(ISize, SizeImpl);\nmixin.define(ISquare);\nmixin.generate().completedSignal.add(function(mixin:Mixin): void\n                                        {\n                                            var square : ISquare = mixin.create(ISquare);\n                                            trace(\"I have a square!\");\n                                        });\n\u003c/code\u003e\u003c/pre\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSimonRichardson%2Fas3-mixins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSimonRichardson%2Fas3-mixins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSimonRichardson%2Fas3-mixins/lists"}