history.as
1.68 KB
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
import mx.collections.ArrayCollection;
[Bindable]
private var history:ArrayCollection;
[Embed(source="images/forward.png")]
[Bindable]
public var FrontImg:Class;
[Embed(source="images/back.png")]
[Bindable]
public var BackImg:Class;
[Embed(source="images/noback.jpg")]
[Bindable]
public var NOBackImg:Class;
[Embed(source="images/nofront.jpg")]
[Bindable]
public var NOFrontImg:Class;
/**
*行业Id
**/
private var currentIndustryId:String = "0";
[Bindable]
private var currentIndex:int=0;
////////////////////////////////////////////
//前进和后退的功能,参考浏览器的前进和后退
// forward and back feature
////////////////////////////////////////////
private function initHistory():void{
history = new ArrayCollection();
}
private function forward():void{
currentIndex = currentIndex+1;
var o:Object = history.getItemAt(currentIndex);
if(o != null){
displayOrgChart(o);
}
}
private function back():void{
currentIndex = currentIndex-1;
var obj:Object = history.getItemAt(currentIndex);
if(obj != null){
displayOrgChart(obj);
}
}
private function home():void{
//var obj:Object = history.getItemAt(0);
//if( obj != null ){
//displayOrgChart(obj);
//}
//currentIndex = 0;
currentIndustryId = "0";
var obj:Object = {id:0, deptType:0, industryId:0, tmode:"temp"};
displayOrgChart(obj);
//chartName.text = "";
history = new ArrayCollection();
}
private function addToHistory(obj:Object):void{
if(currentIndex < history.length){
currentIndex = currentIndex+1;
history.addItemAt(obj, currentIndex);
for(var i:int = currentIndex+1; i< history.length; i++){
history.removeItemAt(i);
}
}else{
history.addItem(obj);
currentIndex = history.length - 1;
}
}