-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathWebViewMultiPage.as
More file actions
108 lines (105 loc) · 2.39 KB
/
WebViewMultiPage.as
File metadata and controls
108 lines (105 loc) · 2.39 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
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
package
{
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.Event;
import flash.geom.Rectangle;
import flash.media.StageWebView;
public class WebViewMultiPage extends MovieClip
{
public static const LOAD_URL:String = "LOAD_URL";
public static const LOAD_STRING:String = "LOAD_STRING";
public static const LOAD_BITMAP:String = "LOAD_BITMAP";
public var autoShowHide:Boolean=true;
private var _stageWebView:StageWebView;
private var _area:MovieClip;
private var _url:String;
private var _stage:Stage;
private var _loadStatus:String;
private var _bitmapData:BitmapData;
public function WebViewMultiPage()
{
super();
}
public function setup(area_p:MovieClip,url_p:String,stage_p:Stage,loadStatus_p:String=LOAD_URL,bitmapData_p:BitmapData=null):void
{
_area = area_p;
_url = url_p;
_stage = stage_p;
_loadStatus = loadStatus_p;
_bitmapData = bitmapData_p;
load();
}
private function chekArea(event:Event):void
{
// TODO Auto-generated method stub
_stageWebView.viewPort = getArea();
if(!Obj.isAccesibleByMouse(_area))
{
hide();
}
else
{
show();
}
}
private function load():void
{
_stageWebView = new StageWebView();
_stageWebView.stage = _stage;
_stageWebView.viewPort = getArea();
if(_loadStatus==LOAD_URL)
{
_stageWebView.loadURL(_url);
}
else if(_loadStatus==LOAD_STRING)
{
_stageWebView.loadString(_url);
}
else if(_loadStatus == LOAD_BITMAP)
{
_stageWebView.drawViewPortToBitmapData(_bitmapData);
}
this.addEventListener(Event.ENTER_FRAME,chekArea)
}
public function reLoad(url_p:String):void
{
_url = url_p;
if(_loadStatus==LOAD_URL)
{
_stageWebView.loadURL(_url);
}
else
{
_stageWebView.loadString(_url);
}
}
public function unload():void
{
if(isActive())
{
this.removeEventListener(Event.ENTER_FRAME,chekArea)
_stageWebView.stage = null;
_stageWebView.dispose();
_stageWebView = null;
}
}
private function getArea():Rectangle
{
return _area.getBounds(_stage)
}
public function hide():void
{
if(isActive() && autoShowHide)_stageWebView.stage = null;
}
public function show():void
{
if(isActive()&& autoShowHide)_stageWebView.stage = _stage;
}
public function isActive():Boolean
{
return _stageWebView!=null
}
}
}