-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_filereference.html
More file actions
245 lines (202 loc) · 9.04 KB
/
example_filereference.html
File metadata and controls
245 lines (202 loc) · 9.04 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<html><head>
<link type="text/css" rel="stylesheet" href="css/reset.css" media="screen"></style>
<link type="text/css" rel="stylesheet" href="css/player.css" media="screen"></style>
<script src="thirdparty/stacktrace.js"></script>
<script src="thirdparty/bytearray.js"></script>
<script src="events/EventDispatcher.js"></script>
<script src="as4js_config.js"></script>
<script src="global.js"></script>
<script src="system/Capabilities.js"></script>
<script src="external/ExternalInterface.js"></script>
<script src="geom/Point.js"></script>
<script src="geom/ColorTransform.js"></script>
<script src="geom/Rectangle.js"></script>
<script src="geom/Matrix.js"></script>
<script src="ui/Keyboard.js"></script>
<script src="ui/KeyboardType.js"></script>
<script src="ui/KeyLocation.js"></script>
<script src="ui/Mouse.js"></script>
<script src="ui/MouseCursor.js"></script>
<script src="ui/MouseCursorData.js"></script>
<script src="events/Event.js"></script>
<script src="events/ActivityEvent.js"></script>
<script src="events/AsyncErrorEvent.js"></script>
<script src="events/ContextMenuEvent.js"></script>
<script src="events/DataEvent.js"></script>
<script src="events/DRMAuthenticationCompleteEvent.js"></script>
<script src="events/DRMAuthenticationErrorEvent.js"></script>
<script src="events/DRMErrorEvent.js"></script>
<script src="events/DRMStatusEvent.js"></script>
<script src="events/ErrorEvent.js"></script>
<script src="events/EventPhase.js"></script>
<script src="events/FocusEvent.js"></script>
<script src="events/FullScreenEvent.js"></script>
<script src="events/GestureEvent.js"></script>
<script src="events/GesturePhase.js"></script>
<script src="events/HTTPStatusEvent.js"></script>
<script src="events/IMEEvent.js"></script>
<script src="events/IOErrorEvent.js"></script>
<script src="events/KeyboardEvent.js"></script>
<script src="events/MouseEvent.js"></script>
<script src="events/NetStatusEvent.js"></script>
<script src="events/PressAndTapGestureEvent.js"></script>
<script src="events/ProgressEvent.js"></script>
<script src="events/SampleDataEvent.js"></script>
<script src="events/SecurityErrorEvent.js"></script>
<script src="events/ShaderEvent.js"></script>
<script src="events/SoftKeyboardEvent.js"></script>
<script src="events/SoftKeyboardTrigger.js"></script>
<script src="events/StageVideoAvailabilityEvent.js"></script>
<script src="events/StageVideoEvent.js"></script>
<script src="events/StatusEvent.js"></script>
<script src="events/SyncEvent.js"></script>
<script src="events/TextEvent.js"></script>
<script src="events/TimerEvent.js"></script>
<script src="events/TouchEvent.js"></script>
<script src="events/TransformGestureEvent.js"></script>
<script src="events/UncaughtErrorEvent.js"></script>
<script src="events/UncaughtErrorEvents.js"></script>
<script src="events/VideoEvent.js"></script>
<script src="net/URLRequestMethod.js"></script>
<script src="net/URLVariables.js"></script>
<script src="net/URLRequest.js"></script>
<script src="net/URLLoader.js"></script>
<script src="net/FileFilter.js"></script>
<script src="net/FileReference.js"></script>
<script src="utils/getTimer.js"></script>
<script src="utils/Timer.js"></script>
<script src="utils/Endian.js"></script>
<script src="utils/ByteArray.js"></script>
<script src="media/SoundTransform.js"></script>
<script src="media/SoundChannel.js"></script>
<script src="media/Sound.js"></script>
<script src="display/BitmapDataChannel.js"></script>
<script src="display/CapStyle.js"></script>
<script src="display/GradientType.js"></script>
<script src="display/InterpolationMethod.js"></script>
<script src="display/JointStyle.js"></script>
<script src="display/SpreadMethod.js"></script>
<script src="display/StageAlign.js"></script>
<script src="display/StageDisplayState.js"></script>
<script src="display/StageOrientation.js"></script>
<script src="display/StageQuality.js"></script>
<script src="display/DisplayObject.js"></script>
<script src="display/InteractiveObject.js"></script>
<script src="display/Shape.js"></script>
<script src="display/Sprite.js"></script>
<script src="display/DisplayObjectContainer.js"></script>
<script src="display/Stage.js"></script>
<script src="display/BitmapData.js"></script>
<script src="display/Bitmap.js"></script>
<script src="display/CapStyle.js"></script>
<script src="display/JointStyle.js"></script>
<script src="display/Graphics.js"></script>
<script src="display/Sprite.js"></script>
<script src="display/LoaderInfo.js"></script>
<script src="display/Loader.js"></script>
<script src="filters/BitmapFilterQuality.js"></script>
<script src="filters/BitmapFilterType.js"></script>
<script src="filters/BitmapFilter.js"></script>
<script src="filters/BevelFilter.js"></script>
<script src="filters/BlurFilter.js"></script>
<script src="filters/ColorMatrixFilter.js"></script>
<script src="filters/ConvolutionFilter.js"></script>
<script src="filters/DisplacementMapFilterMode.js"></script>
<script src="filters/DisplacementMapFilter.js"></script>
<script src="filters/DropShadowFilter.js"></script>
<script src="filters/GlowFilter.js"></script>
<script src="filters/GradientBevelFilter.js"></script>
<script src="filters/GradientGlowFilter.js"></script>
<script src="text/TextField.js"></script>
<script src="xml/XMLNodeType.js"></script>
<script src="xml/XMLNode.js"></script>
<script src="xml/XMLDocument.js"></script>
<script lang="javascript">
function init(){
var mFileReference;
var textArea = new TextField();
textArea.border=true;
textArea.borderColor = 0xFF0000;
textArea.backgroundColor = 0xFFFFFF;
textArea.y = 50;
textArea.width = 400;
textArea.height = 400;
var test = new DisplayObjectContainer("stage");
var browseButton = new Sprite("browseButton");
var saveButton = new Sprite("saveButton");
test.addChild(textArea);
var uploadedFilePath = "";
//This function is called after user selected a file in the file browser dialog.
//This function is called to notify us of the uploading progress
function onProgress(event)
{
var percentLoaded=event.bytesLoaded/event.bytesTotal*100;
//trace("loaded: "+percentLoaded+"%");
}
function onUploadComplete(e){
navigateToURL(new URLRequest(uploadedFilePath), "_blank")
};
//This function is called after the file has been uploaded.
function onFileLoaded(event)
{
var data=event.target.data;
textArea.htmlText="<font color='#000000'>"+data.toString()+"</font>";
browseButton.visible=true;
mFileReference.removeEventListener(Event.COMPLETE, onFileLoaded);
mFileReference.removeEventListener(IOErrorEvent.IO_ERROR, onFileLoadError);
mFileReference.removeEventListener(ProgressEvent.PROGRESS, onProgress);
//upload file
var filename=mFileReference.name;
var urlRequest= new URLRequest("uploadFile.php");
urlRequest.method = URLRequestMethod.POST;
uploadedFilePath = mFileReference.name;
// mFileReference.addEventListener(ProgressEvent.PROGRESS, onProgress);
mFileReference.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,onUploadComplete);
mFileReference.upload(urlRequest);
}
function onFileLoadError(event)
{
// Hide progress bar
browseButton.visible=true;
mFileReference.removeEventListener(Event.COMPLETE, onFileLoaded);
mFileReference.removeEventListener(IOErrorEvent.IO_ERROR, onFileLoadError);
mFileReference.removeEventListener(ProgressEvent.PROGRESS, onProgress);
}
function onFileSelected(event)
{
// This callback will be called when the file is uploaded and ready to use
mFileReference.addEventListener(Event.COMPLETE, onFileLoaded);
// This callback will be called if there's error during uploading
mFileReference.addEventListener(IOErrorEvent.IO_ERROR, onFileLoadError);
// Optional callback to track progress of uploading
mFileReference.addEventListener(ProgressEvent.PROGRESS, onProgress);
// Tells the FileReference to load the file
mFileReference.load();
browseButton.visible=false;
}
//This function is called when the BROWSE button is clicked.
function onBrowseButtonClicked(event)
{
mFileReference=new FileReference();
mFileReference.addEventListener(Event.SELECT, onFileSelected);
var swfTypeFilter = new FileFilter("Text Files","*.txt; *.html;*.htm;*.php");
var allTypeFilter = new FileFilter("All Files (*.*)","*.*");
mFileReference.browse([swfTypeFilter, allTypeFilter]);
}
function handleSave(e){
mFileReference.save();
};
//Setup button to handle browsing
browseButton.addEventListener(MouseEvent.CLICK, onBrowseButtonClicked);
saveButton.addEventListener(MouseEvent.CLICK,handleSave);
saveButton.x = 140;
};
</script>
</head>
<body onload="init();" bgcolor="0" style="background-color:#000000;">
<div id="stage">
<div id="browseButton" style="background-color:#ff0000;color:#ffffff;width:100px;height:25px;">Browse</div>
<div id="saveButton" style="background-color:#ff0000;color:#ffffff;width:100px;height:25px;">Save</div>
</div>
</body>
</html>