actionscript.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. ace.define("ace/snippets/actionscript",[], function(require, exports, module) {
  2. "use strict";
  3. exports.snippetText = "snippet main\n\
  4. package {\n\
  5. import flash.display.*;\n\
  6. import flash.Events.*;\n\
  7. \n\
  8. public class Main extends Sprite {\n\
  9. public function Main ( ) {\n\
  10. trace(\"start\");\n\
  11. stage.scaleMode = StageScaleMode.NO_SCALE;\n\
  12. stage.addEventListener(Event.RESIZE, resizeListener);\n\
  13. }\n\
  14. \n\
  15. private function resizeListener (e:Event):void {\n\
  16. trace(\"The application window changed size!\");\n\
  17. trace(\"New width: \" + stage.stageWidth);\n\
  18. trace(\"New height: \" + stage.stageHeight);\n\
  19. }\n\
  20. \n\
  21. }\n\
  22. \n\
  23. }\n\
  24. snippet class\n\
  25. ${1:public|internal} class ${2:name} ${3:extends } {\n\
  26. public function $2 ( ) {\n\
  27. (\"start\");\n\
  28. }\n\
  29. }\n\
  30. snippet all\n\
  31. package name {\n\
  32. \n\
  33. ${1:public|internal|final} class ${2:name} ${3:extends } {\n\
  34. private|public| static const FOO = \"abc\";\n\
  35. private|public| static var BAR = \"abc\";\n\
  36. \n\
  37. // class initializer - no JIT !! one time setup\n\
  38. if Cababilities.os == \"Linux|MacOS\" {\n\
  39. FOO = \"other\";\n\
  40. }\n\
  41. \n\
  42. // constructor:\n\
  43. public function $2 ( ){\n\
  44. super2();\n\
  45. trace(\"start\");\n\
  46. }\n\
  47. public function name (a, b...){\n\
  48. super.name(..);\n\
  49. lable:break\n\
  50. }\n\
  51. }\n\
  52. }\n\
  53. \n\
  54. function A(){\n\
  55. // A can only be accessed within this file\n\
  56. }\n\
  57. snippet switch\n\
  58. switch(${1}){\n\
  59. case ${2}:\n\
  60. ${3}\n\
  61. break;\n\
  62. default:\n\
  63. }\n\
  64. snippet case\n\
  65. case ${1}:\n\
  66. ${2}\n\
  67. break;\n\
  68. snippet package\n\
  69. package ${1:package}{\n\
  70. ${2}\n\
  71. }\n\
  72. snippet wh\n\
  73. while ${1:cond}{\n\
  74. ${2}\n\
  75. }\n\
  76. snippet do\n\
  77. do {\n\
  78. ${2}\n\
  79. } while (${1:cond})\n\
  80. snippet while\n\
  81. while ${1:cond}{\n\
  82. ${2}\n\
  83. }\n\
  84. snippet for enumerate names\n\
  85. for (${1:var} in ${2:object}){\n\
  86. ${3}\n\
  87. }\n\
  88. snippet for enumerate values\n\
  89. for each (${1:var} in ${2:object}){\n\
  90. ${3}\n\
  91. }\n\
  92. snippet get_set\n\
  93. function get ${1:name} {\n\
  94. return ${2}\n\
  95. }\n\
  96. function set $1 (newValue) {\n\
  97. ${3}\n\
  98. }\n\
  99. snippet interface\n\
  100. interface name {\n\
  101. function method(${1}):${2:returntype};\n\
  102. }\n\
  103. snippet try\n\
  104. try {\n\
  105. ${1}\n\
  106. } catch (error:ErrorType) {\n\
  107. ${2}\n\
  108. } finally {\n\
  109. ${3}\n\
  110. }\n\
  111. # For Loop (same as c.snippet)\n\
  112. snippet for for (..) {..}\n\
  113. for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {\n\
  114. ${4:/* code */}\n\
  115. }\n\
  116. # Custom For Loop\n\
  117. snippet forr\n\
  118. for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {\n\
  119. ${5:/* code */}\n\
  120. }\n\
  121. # If Condition\n\
  122. snippet if\n\
  123. if (${1:/* condition */}) {\n\
  124. ${2:/* code */}\n\
  125. }\n\
  126. snippet el\n\
  127. else {\n\
  128. ${1}\n\
  129. }\n\
  130. # Ternary conditional\n\
  131. snippet t\n\
  132. ${1:/* condition */} ? ${2:a} : ${3:b}\n\
  133. snippet fun\n\
  134. function ${1:function_name}(${2})${3}\n\
  135. {\n\
  136. ${4:/* code */}\n\
  137. }\n\
  138. # FlxSprite (usefull when using the flixel library)\n\
  139. snippet FlxSprite\n\
  140. package\n\
  141. {\n\
  142. import org.flixel.*\n\
  143. \n\
  144. public class ${1:ClassName} extends ${2:FlxSprite}\n\
  145. {\n\
  146. public function $1(${3: X:Number, Y:Number}):void\n\
  147. {\n\
  148. super(X,Y);\n\
  149. ${4: //code...}\n\
  150. }\n\
  151. \n\
  152. override public function update():void\n\
  153. {\n\
  154. super.update();\n\
  155. ${5: //code...}\n\
  156. }\n\
  157. }\n\
  158. }\n\
  159. \n\
  160. ";
  161. exports.scope = "actionscript";
  162. });
  163. (function() {
  164. ace.require(["ace/snippets/actionscript"], function(m) {
  165. if (typeof module == "object" && typeof exports == "object" && module) {
  166. module.exports = m;
  167. }
  168. });
  169. })();