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
//函數宣告
function Step1():void{...}
function sTep2():void{...}
function stEp3():void{...}
function steP4():void{...}
//函數執行
Step1();
sTep2();
stEp3();
steP4();

//       ↓

//在這裡弄出一個變數型態
public interface IStep{
   function execute():void;
}
//和一些變數 去包裝不同的部分
public class Setp1 implements IStep{
   public function execute():void{ return Step1(); }
}
public class Setp2 implements IStep{
   public function execute():void{ return sTep2(); }
}
public class Setp3 implements IStep{
   public function execute():void{ return stEp3(); }
}
public class Setp4 implements IStep{
   public function execute():void{ return steP4(); }
}

//就可以做成陣列
var array:Array = [new Setp1(),new Setp2(),new Setp3(),new Setp4()];

//用迴圈執行
for(var i = 0 ; i < 4 ; i++){
   var step:IStep = array[i];
   step.execute();
}