aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-snippets/snippets/actionscript.snippets
blob: b7aa7cb3342e7f85cfb5f73c50125f77d87a7e0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
snippet main
	package {
		import flash.display.*;
		import flash.Events.*;

		public class Main extends Sprite {
			public function Main (	) {
				trace("start");
				stage.scaleMode = StageScaleMode.NO_SCALE;
				stage.addEventListener(Event.RESIZE, resizeListener);
			}

			private function resizeListener (e:Event):void {
				trace("The application window changed size!");
				trace("New width:  " + stage.stageWidth);
				trace("New height: " + stage.stageHeight);
			}

		}

	}
snippet class
	${1:public|internal} class ${2:name} ${0:extends } {
		public function $2 (	) {
			("start");
		}
	}
snippet all
	package name {

		${1:public|internal|final} class ${2:name} ${0:extends } {
			private|public| static const FOO = "abc";
			private|public| static var BAR = "abc";

			// class initializer - no JIT !! one time setup
			if Cababilities.os == "Linux|MacOS" {
				FOO = "other";
			}

			// constructor:
			public function $2 (	){
				super2();
				trace("start");
			}
			public function name (a, b...){
				super.name(..);
				lable:break
			}
		}
	}

	function A(){
		// A can only be accessed within this file
	}
snippet switch
	switch(${1}){
		case ${2}:
			${0}
		break;
		default:
	}
snippet case
		case ${1}:
			${0}
		break;
snippet package
	package ${1:package}{
		${0}
	}
snippet wh
	while ${1:cond}{
		${0}
	}
snippet do
	do {
		${0}
	} while (${1:cond})
snippet for enumerate names
	for (${1:var} in ${2:object}){
		${0}
	}
snippet for enumerate values
	for each (${1:var} in ${2:object}){
		${0}
	}
snippet get_set
	function get ${1:name} {
		return ${2}
	}
	function set $1 (newValue) {
		${0}
	}
snippet interface
	interface name {
		function method(${1}):${0:returntype};
	}
snippet try
	try {
		${1}
	} catch (error:ErrorType) {
		${2}
	} finally {
		${0}
	}
# For Loop (same as c.snippet)
snippet for for (..) {..}
	for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
		${0}
	}
# Custom For Loop
snippet forr
	for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
		${0}
	}
# If Condition
snippet if
	if (${1:/* condition */}) {
		${0}
	}
snippet el
	else {
		${0}
	}
# Ternary conditional
snippet t
	${1:/* condition */} ? ${2:a} : ${0:b}
snippet fun
	function ${1:function_name}(${2})${3}
	{
		${0}
	}
# FlxSprite (usefull when using the flixel library)
snippet FlxSprite
	package
	{
		import org.flixel.*

		public class ${1:ClassName} extends ${2:FlxSprite}
		{
			public function $1(${3: X:Number, Y:Number}):void
			{
				super(X,Y);
				${4}
			}

			override public function update():void
			{
				super.update();
				${0}
			}
		}
	}