{"id":13744052,"url":"https://github.com/loteixeira/AS3console","last_synced_at":"2025-05-09T02:32:19.684Z","repository":{"id":143053157,"uuid":"2122539","full_name":"loteixeira/AS3console","owner":"loteixeira","description":"A logging system for Actionscript3","archived":false,"fork":false,"pushed_at":"2014-02-11T19:53:37.000Z","size":5156,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-15T15:41:52.880Z","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":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loteixeira.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-07-29T06:18:38.000Z","updated_at":"2016-10-18T05:45:33.000Z","dependencies_parsed_at":"2023-03-22T10:48:14.644Z","dependency_job_id":null,"html_url":"https://github.com/loteixeira/AS3console","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loteixeira%2FAS3console","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loteixeira%2FAS3console/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loteixeira%2FAS3console/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loteixeira%2FAS3console/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loteixeira","download_url":"https://codeload.github.com/loteixeira/AS3console/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253177787,"owners_count":21866401,"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:02.084Z","updated_at":"2025-05-09T02:32:19.374Z","avatar_url":"https://github.com/loteixeira.png","language":"ActionScript","readme":"# AS3console0.6.2\nAS3console is a component designed to manage input/output for Actionscript3 (Flash, Flex and AIR). It's a generic logging system, where you can use the same interface\nfor several IO streams (trace, js console.log, server communication, etc) including a simple GUI accessible from anywhere (available through flash right click menu or shortcut Ctrl+M).\n\n**Download the last tag:** https://github.com/loteixeira/AS3console/archive/v0.6.2.zip \u003cbr\u003e\n**Online demo:** http://disturbedcoder.com/files/as3console/as3console-demo.swf \u003cbr\u003e\n**Online documentation:** http://disturbedcoder.com/files/as3console/doc/\n\nThis software is distribuited under the terms of the GNU Lesser Public License.\n\n## Usage\nYou have two options to work with as3console:\n\n* a singleton - accessible from anywhere in the code\n* objects - where you need manage your own instances\n\n### Singleton Style\nIt's very simple to work with AS3console singleton because you don't need to worry about any object. Plus, you may use a top-level function to write into the log system.\n\nHere's the simplest scenario of AS3console usage:\n\n```actionscript\nimport br.dcoder.console.Console;\nimport flash.display.Sprite;\n\npublic class MySprite extends Sprite\n{\n\tpublic function MySprite()\n\t{\n\t\tConsole.create(this);\n\t\tcpln(\"Hello World!\");\n\t}\n}\n```\n\nThe top level function cpln is a alias which internally calls the singleton instance. The code below does exactly the same thing:\n\n```actionscript\nimport br.dcoder.console.Console;\nimport flash.display.Sprite;\n\npublic class MySprite extends Sprite\n{\n\tpublic function MySprite()\n\t{\n\t\tConsole.create(this);\n\t\t// same effect than calling cpln(\"Hello World!\");\n\t\tConsole.instance.println(\"Hello World!\");\n\t}\n}\n```\n\nThe variable accessed through Console.instance is an object of ConsoleCore class.\n\n### Object Style\nUsing objects you can manage several instances of AS3console (ConsoleCore class).\n\n```actionscript\nimport br.dcoder.console.ConsoleCore;\nimport flash.display.Sprite;\n\npublic class MySprite extends Sprite\n{\n\tpublic function MySprite()\n\t{\n\t\tvar consoleCore:ConsoleCore = new ConsoleCore(this);\n\t\tconsoleCore.println(\"Hello World!\");\n\t\t// at this point Console.instance is undefined\n\t\t// thus, you need to keep the instance\n\t}\n}\n```\n\n### IO Events/Redirects\n\nEvery input or output action dispatches an event. You may listen the EventDispatcher related to ConsoleCore to handle the data.\n\n#### Output Events\n\nThe code below listens and sends every output to a server.\n\n```actionscript\nimport br.dcoder.console.Console;\nimport br.dcoder.console.ConsoleEvent;\nimport flash.display.Sprite;\n\npublic class MySprite extends Sprite\n{\n\tpublic function MySprite()\n\t{\n\t\tConsole.create(this);\n\t\tConsole.instance.getEventDispatcher().addEventListener(ConsoleEvent.OUTPUT, output);\n\t}\n\n\tprivate function output(e:ConsoleEvent):void\n\t{\n\t\tsendToServer(e.text);\n\t}\n\n\tprivate function sendToServer(str:String):void\n\t{\n\t\t// send the data to a hypothetical server\n\t}\n}\n```\n\n#### Input Events\n\nIt's possible to create commands listening for input events. These events are dispatched when the user types text in the input field or when scan method is called.\n\n```actionscript\nimport br.dcoder.console.Console;\nimport br.dcoder.console.ConsoleEvent;\nimport flash.display.Sprite;\n\npublic class MySprite extends Sprite\n{\n\tpublic function MySprite()\n\t{\n\t\tConsole.create(this);\n\t\tConsole.instance.getEventDispatcher().addEventListener(ConsoleEvent.INPUT, input);\n\t\tcpln(\"Type 'number'...\");\n\n\t\t// inputing \"number\" string into console\n\t\tConsole.instance.scan(\"number\");\n\t\t// you may also type this text in gui input field\n\t}\n\n\tprivate function input(e:ConsoleEvent):void\n\t{\n\t\tif (e.text == \"number\")\n\t\t\tcpln(42);\n\t}\n}\n```\n\n#### Redirect to trace\n\nBy default, every output is also redirected to the top-level function trace.\n\n```actionscript\nimport br.dcoder.console.Console;\nimport br.dcoder.console.ConsoleEvent;\nimport flash.display.Sprite;\n\npublic class MySprite extends Sprite\n{\n\tpublic function MySprite()\n\t{\n\t\tConsole.create(this);\n\t\t// turning off trace redirect\n\t\tConsole.instance.config.traceEcho = false;\n\t}\n}\n```\n\n#### Redirect to JS console.log\n\nBy default, this feature is turned off. But whether you use it, every output event is redirected to JavaScript console.log function.\n\n```actionscript\nimport br.dcoder.console.Console;\nimport br.dcoder.console.ConsoleEvent;\nimport flash.display.Sprite;\n\npublic class MySprite extends Sprite\n{\n\tpublic function MySprite()\n\t{\n\t\tConsole.create(this);\n\t\t// turning on js redirect - every output will reach JavaScript console\n\t\tConsole.instance.config.jsEcho = true;\n\t}\n}\n```\n\n### Without GUI\n\nIf you don't provide a parent DisplayObjectContainer when creating the console, it'll be created without a graphical interface. However, all features still work.\nAlso, the context menu item won't be created.\n\n```actionscript\nimport br.dcoder.console.Console;\nimport br.dcoder.console.ConsoleEvent;\nimport flash.display.Sprite;\n\npublic class MySprite extends Sprite\n{\n\tpublic function MySprite()\n\t{\n\t\t// no GUI!\n\t\t// however events and redirects still working\n\t\tConsole.create(); // same than calling Console.create(null);\n\t\tcpln(\"Hello non graphical world!\");\n\t}\n}\n```","funding_links":[],"categories":["Frameworks"],"sub_categories":["Logger Framework"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floteixeira%2FAS3console","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floteixeira%2FAS3console","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floteixeira%2FAS3console/lists"}