This repository has been archived by the owner on Jan 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathASExpander.jsfl
80 lines (74 loc) · 4.45 KB
/
ASExpander.jsfl
1
/** * ASExpander.jsfl * version 1.1.3 * * Copyright (c) 2008 Keith Peters * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * * Changes: * 1.1 Started using actionsPanel.getText, setText. And setSelection for cursor position. * 1.1.1 Fixed a typo in enterFrame * 1.1.2 Not correctly finding end of file if no cursor specified. So specified cursor at end of each snippet. Added some snippets. * 1.1.3 Added help function. Type &help and run command and it traces out a list of commands. */map = new Object();map["&help"] = "";map["&meta"] = "[SWF(width=800, height=800, backgroundColor=0xffffff, frameRate=31)]&cursor";map["&stage"] = "stage.align = StageAlign.TOP_LEFT;\nstage.scaleMode = StageScaleMode.NO_SCALE;&cursor";map["&resize"] = "stage.addEventListener(Event.RESIZE, stageResizeHandler);\nfunction stageResizeHandler(event:Event)\n{\n\t&cursor\n}";map["&bitmap"] = "var bmpd:BitmapData = new BitmapData(800, 800, false, 0xffffff);\nvar bmp:Bitmap = addChild(new Bitmap(bmpd)) as Bitmap;&cursor";map["&enterFrame"] = "addEventListener(Event.ENTER_FRAME, enterFrameHandler);\nfunction enterFrameHandler(event:Event):void\n{\n\t&cursor\n}";map["&mouseDown"] = "stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);\nfunction mouseDownHandler(event:MouseEvent):void\n{\n\t&cursor\n}";map["&mouseUp"] = "stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);\nfunction mouseUpHandler(event:MouseEvent):void\n{\n\t&cursor\n}";map["&mouseMove"] = "stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);\nfunction mouseMoveHandler(event:MouseEvent):void\n{\n\t&cursor\n}";map["&keyDown"] = "stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);\nfunction keyDownHandler(event:KeyboardEvent):void\n{\n\t&cursor\n}";map["&keyUp"] = "stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);\nfunction keyUpHandler(event:KeyboardEvent):void\n{\n\t&cursor\n}";map["&loop"] = "for(var i:int = 0; i < 10; i++)\n{\n\t&cursor\n}";map["&2loop"] = "for(var i:int = 0; i < 10; i++)\n{\n\tfor(var j:int = 0; j < 10; j++)\n\t{\n\t\t&cursor\n\t}\n}";map["&embed"] = "[Embed(source=\"sourcefile\")]\nvar theClass:Class;&cursor";map["&click"] = "btn.addEventListener(MouseEvent.CLICK, onClick);\nfunction onClick(event:MouseEvent):void\n{\n\t&cursor\n}";map["&sprite"] = "var s:Sprite = addChild(new Sprite()) as Sprite;&cursor";map["&mc"] = "var mc:MovieClip = addChild(new MovieClip()) as MovieClip;&cursor";map["&tf2"] = "var tf:TextField = addChild(new TextField()) as TextField;\ntf.autoSize = TextFieldAutoSize.LEFT;\ntf.selectable = false;\ntf.multiline = true;\ntf.wordWrap = true;\ntf.defaultTextFormat = new TextFormat(\"Arial\", 12, 0);\ntf.text = \"hello\";&cursor";map["&tf"] = "var tf:TextField = addChild(new TextField()) as TextField;&cursor";script = fl.actionsPanel.getText();if(script.indexOf("&help") != -1){ fl.trace("ASExpander keys:"); for(key in map) { fl.trace(key); }}for(key in map){ script = script.split(key).join(map[key]);}// set text, along with cursor location infofl.actionsPanel.setText(script);// search for &curso. does not find &cursor if followed by \nindex = fl.actionsPanel.getText().indexOf("&curso");// if no cursor info, index = end of fileif(index == -1) index = fl.actionsPanel.getText().length;// set text again, without cursor infofl.actionsPanel.setText(script.split("&cursor").join(""));// set selection to where cursor was, or end of file.fl.actionsPanel.setSelection(index, 0);