@awayjs/scene 0.13.264 → 0.13.266
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +100 -100
- package/README.md +61 -61
- package/bundle/awayjs-scene.umd.js +2 -2
- package/bundle/awayjs-scene.umd.js.map +1 -1
- package/copyVersionToIndex.js +23 -23
- package/dist/index.d.ts +76 -75
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -66
- package/dist/lib/Scene.d.ts +84 -84
- package/dist/lib/Scene.js +288 -288
- package/dist/lib/Settings.d.ts +16 -16
- package/dist/lib/Settings.js +60 -60
- package/dist/lib/adapters/IDisplayObjectAdapter.d.ts +13 -13
- package/dist/lib/adapters/IDisplayObjectAdapter.js +1 -1
- package/dist/lib/adapters/IFilter.d.ts +24 -24
- package/dist/lib/adapters/IFilter.js +1 -1
- package/dist/lib/adapters/IMovieClipAdapter.d.ts +14 -14
- package/dist/lib/adapters/IMovieClipAdapter.js +1 -1
- package/dist/lib/adapters/ITextfieldAdapter.d.ts +4 -4
- package/dist/lib/adapters/ITextfieldAdapter.js +1 -1
- package/dist/lib/base/IBitmapDrawable.d.ts +11 -11
- package/dist/lib/base/IBitmapDrawable.js +1 -1
- package/dist/lib/base/IFrameLabel.d.ts +4 -4
- package/dist/lib/base/IFrameLabel.js +1 -1
- package/dist/lib/base/IFrameScript.d.ts +5 -5
- package/dist/lib/base/IFrameScript.js +1 -1
- package/dist/lib/base/MouseButtons.d.ts +26 -22
- package/dist/lib/base/MouseButtons.d.ts.map +1 -1
- package/dist/lib/base/MouseButtons.js +1 -1
- package/dist/lib/base/Timeline.d.ts +148 -148
- package/dist/lib/base/Timeline.js +535 -535
- package/dist/lib/base/TimelineActionType.d.ts +18 -18
- package/dist/lib/base/TimelineActionType.js +1 -1
- package/dist/lib/controllers/ControllerBase.d.ts +14 -14
- package/dist/lib/controllers/ControllerBase.js +60 -60
- package/dist/lib/controllers/FirstPersonController.d.ts +78 -78
- package/dist/lib/controllers/FirstPersonController.js +228 -228
- package/dist/lib/controllers/FollowController.d.ts +12 -12
- package/dist/lib/controllers/FollowController.js +27 -27
- package/dist/lib/controllers/HoverController.d.ts +105 -105
- package/dist/lib/controllers/HoverController.js +302 -302
- package/dist/lib/controllers/LookAtController.d.ts +14 -14
- package/dist/lib/controllers/LookAtController.js +68 -68
- package/dist/lib/controllers/SpringController.d.ts +38 -38
- package/dist/lib/controllers/SpringController.js +59 -59
- package/dist/lib/display/Billboard.d.ts +147 -147
- package/dist/lib/display/Billboard.js +426 -426
- package/dist/lib/display/Camera.d.ts +40 -40
- package/dist/lib/display/Camera.js +90 -90
- package/dist/lib/display/DisplayObject.d.ts +938 -938
- package/dist/lib/display/DisplayObject.js +1641 -1641
- package/dist/lib/display/DisplayObjectContainer.d.ts +325 -325
- package/dist/lib/display/DisplayObjectContainer.js +480 -480
- package/dist/lib/display/LineSegment.d.ts +84 -84
- package/dist/lib/display/LineSegment.js +215 -215
- package/dist/lib/display/LoaderContainer.d.ts +504 -504
- package/dist/lib/display/LoaderContainer.js +603 -603
- package/dist/lib/display/MorphSprite.d.ts +20 -20
- package/dist/lib/display/MorphSprite.js +254 -254
- package/dist/lib/display/MovieClip.d.ts +152 -152
- package/dist/lib/display/MovieClip.js +735 -735
- package/dist/lib/display/SimpleButton.d.ts +158 -158
- package/dist/lib/display/SimpleButton.js +228 -228
- package/dist/lib/display/Skybox.d.ts +156 -156
- package/dist/lib/display/Skybox.js +309 -309
- package/dist/lib/display/Sprite.d.ts +70 -70
- package/dist/lib/display/Sprite.js +144 -144
- package/dist/lib/display/TextField.d.ts +1109 -1109
- package/dist/lib/display/TextField.js +3109 -3109
- package/dist/lib/display/TextSprite.d.ts +10 -10
- package/dist/lib/display/TextSprite.js +25 -25
- package/dist/lib/elements/SkyboxElements.d.ts +29 -29
- package/dist/lib/elements/SkyboxElements.js +127 -127
- package/dist/lib/errors/CastError.d.ts +4 -4
- package/dist/lib/errors/CastError.js +10 -10
- package/dist/lib/events/CameraEvent.d.ts +16 -16
- package/dist/lib/events/CameraEvent.js +30 -30
- package/dist/lib/events/FocusEvent.d.ts +42 -42
- package/dist/lib/events/FocusEvent.js +43 -43
- package/dist/lib/events/KeyboardEvent.d.ts +21 -21
- package/dist/lib/events/KeyboardEvent.js +43 -43
- package/dist/lib/events/MouseEvent.d.ts +91 -184
- package/dist/lib/events/MouseEvent.d.ts.map +1 -1
- package/dist/lib/events/MouseEvent.js +122 -191
- package/dist/lib/events/PointerEvent.d.ts +94 -0
- package/dist/lib/events/PointerEvent.d.ts.map +1 -0
- package/dist/lib/events/PointerEvent.js +73 -0
- package/dist/lib/events/ResizeEvent.d.ts +15 -15
- package/dist/lib/events/ResizeEvent.js +38 -38
- package/dist/lib/events/TextfieldEvent.d.ts +19 -19
- package/dist/lib/events/TextfieldEvent.js +28 -28
- package/dist/lib/events/TouchEvent.d.ts +51 -0
- package/dist/lib/events/TouchEvent.d.ts.map +1 -0
- package/dist/lib/events/TouchEvent.js +83 -0
- package/dist/lib/factories/DefaultSceneGraphFactory.d.ts +26 -26
- package/dist/lib/factories/DefaultSceneGraphFactory.js +54 -54
- package/dist/lib/factories/ISceneGraphFactory.d.ts +20 -20
- package/dist/lib/factories/ISceneGraphFactory.js +1 -1
- package/dist/lib/image/SceneImage2D.d.ts +236 -236
- package/dist/lib/image/SceneImage2D.js +687 -687
- package/dist/lib/managers/DefaultFontManager.d.ts +14 -14
- package/dist/lib/managers/DefaultFontManager.js +101 -101
- package/dist/lib/managers/DeviceFontManager.d.ts +8 -8
- package/dist/lib/managers/DeviceFontManager.js +44 -44
- package/dist/lib/managers/FrameScriptManager.d.ts +36 -36
- package/dist/lib/managers/FrameScriptManager.js +377 -377
- package/dist/lib/managers/IInputRecorder.d.ts +3 -3
- package/dist/lib/managers/IInputRecorder.js +1 -1
- package/dist/lib/managers/MouseManager.d.ts +76 -89
- package/dist/lib/managers/MouseManager.d.ts.map +1 -1
- package/dist/lib/managers/MouseManager.js +809 -759
- package/dist/lib/prefabs/PrefabBase.d.ts +19 -19
- package/dist/lib/prefabs/PrefabBase.js +42 -42
- package/dist/lib/prefabs/PrimitiveCapsulePrefab.d.ts +56 -56
- package/dist/lib/prefabs/PrimitiveCapsulePrefab.js +269 -269
- package/dist/lib/prefabs/PrimitiveConePrefab.d.ts +21 -21
- package/dist/lib/prefabs/PrimitiveConePrefab.js +43 -43
- package/dist/lib/prefabs/PrimitiveCubePrefab.d.ts +74 -74
- package/dist/lib/prefabs/PrimitiveCubePrefab.js +545 -545
- package/dist/lib/prefabs/PrimitiveCylinderPrefab.d.ts +79 -79
- package/dist/lib/prefabs/PrimitiveCylinderPrefab.js +584 -584
- package/dist/lib/prefabs/PrimitivePlanePrefab.d.ts +65 -65
- package/dist/lib/prefabs/PrimitivePlanePrefab.js +300 -300
- package/dist/lib/prefabs/PrimitivePolygonPrefab.d.ts +29 -29
- package/dist/lib/prefabs/PrimitivePolygonPrefab.js +64 -64
- package/dist/lib/prefabs/PrimitivePrefabBase.d.ts +67 -67
- package/dist/lib/prefabs/PrimitivePrefabBase.js +158 -158
- package/dist/lib/prefabs/PrimitiveSpherePrefab.d.ts +48 -48
- package/dist/lib/prefabs/PrimitiveSpherePrefab.js +294 -294
- package/dist/lib/prefabs/PrimitiveTorusPrefab.d.ts +55 -55
- package/dist/lib/prefabs/PrimitiveTorusPrefab.js +260 -260
- package/dist/lib/text/AntiAliasType.d.ts +24 -24
- package/dist/lib/text/AntiAliasType.js +28 -28
- package/dist/lib/text/BitmapFontChar.d.ts +39 -39
- package/dist/lib/text/BitmapFontChar.js +42 -42
- package/dist/lib/text/BitmapFontTable.d.ts +80 -80
- package/dist/lib/text/BitmapFontTable.js +203 -203
- package/dist/lib/text/FNTGenerator.d.ts +10 -10
- package/dist/lib/text/FNTGenerator.js +74 -74
- package/dist/lib/text/FNTGeneratorCanvas.d.ts +22 -22
- package/dist/lib/text/FNTGeneratorCanvas.js +205 -205
- package/dist/lib/text/FNTGeneratrorBase.d.ts +7 -7
- package/dist/lib/text/FNTGeneratrorBase.js +7 -7
- package/dist/lib/text/Font.d.ts +38 -38
- package/dist/lib/text/Font.js +109 -109
- package/dist/lib/text/FontLookUpMode.d.ts +5 -5
- package/dist/lib/text/FontLookUpMode.js +7 -7
- package/dist/lib/text/FontStyleName.d.ts +6 -6
- package/dist/lib/text/FontStyleName.js +7 -7
- package/dist/lib/text/GridFitType.d.ts +31 -31
- package/dist/lib/text/GridFitType.js +35 -35
- package/dist/lib/text/HTMLTextProcessor.d.ts +8 -8
- package/dist/lib/text/HTMLTextProcessor.js +423 -423
- package/dist/lib/text/IFontTable.d.ts +16 -16
- package/dist/lib/text/IFontTable.js +1 -1
- package/dist/lib/text/TesselatedFontChar.d.ts +58 -58
- package/dist/lib/text/TesselatedFontChar.js +66 -66
- package/dist/lib/text/TesselatedFontTable.d.ts +95 -95
- package/dist/lib/text/TesselatedFontTable.js +992 -992
- package/dist/lib/text/TextFieldAutoSize.d.ts +28 -28
- package/dist/lib/text/TextFieldAutoSize.js +32 -32
- package/dist/lib/text/TextFieldType.d.ts +20 -20
- package/dist/lib/text/TextFieldType.js +24 -24
- package/dist/lib/text/TextFormat.d.ts +273 -273
- package/dist/lib/text/TextFormat.js +440 -440
- package/dist/lib/text/TextFormatAlign.d.ts +26 -26
- package/dist/lib/text/TextFormatAlign.js +30 -30
- package/dist/lib/text/TextInteractionMode.d.ts +21 -21
- package/dist/lib/text/TextInteractionMode.js +25 -25
- package/dist/lib/text/TextLineMetrics.d.ts +61 -61
- package/dist/lib/text/TextLineMetrics.js +42 -42
- package/dist/lib/text/TextShape.d.ts +20 -20
- package/dist/lib/text/TextShape.js +75 -75
- package/dist/lib/tools/Merge.d.ts +81 -81
- package/dist/lib/tools/Merge.js +266 -266
- package/dist/lib/utils/Cast.d.ts +20 -20
- package/dist/lib/utils/Cast.js +271 -271
- package/index.ts +92 -91
- package/lib/Scene.ts +343 -343
- package/lib/Settings.ts +83 -83
- package/lib/adapters/IDisplayObjectAdapter.ts +23 -23
- package/lib/adapters/IFilter.ts +25 -25
- package/lib/adapters/IMovieClipAdapter.ts +24 -24
- package/lib/adapters/ITextfieldAdapter.ts +6 -6
- package/lib/base/IBitmapDrawable.ts +13 -13
- package/lib/base/IFrameLabel.ts +3 -3
- package/lib/base/IFrameScript.ts +4 -4
- package/lib/base/MouseButtons.ts +31 -26
- package/lib/base/Timeline.ts +727 -727
- package/lib/base/TimelineActionType.ts +18 -18
- package/lib/controllers/ControllerBase.ts +66 -66
- package/lib/controllers/FirstPersonController.ts +241 -241
- package/lib/controllers/FollowController.ts +22 -22
- package/lib/controllers/HoverController.ts +304 -304
- package/lib/controllers/LookAtController.ts +75 -75
- package/lib/controllers/SpringController.ts +91 -91
- package/lib/display/Billboard.ts +504 -504
- package/lib/display/Camera.ts +89 -89
- package/lib/display/DisplayObject.ts +1893 -1893
- package/lib/display/DisplayObjectContainer.ts +538 -538
- package/lib/display/LineSegment.ts +248 -248
- package/lib/display/LoaderContainer.ts +651 -651
- package/lib/display/MorphSprite.ts +347 -347
- package/lib/display/MovieClip.ts +879 -879
- package/lib/display/SimpleButton.ts +224 -224
- package/lib/display/Skybox.ts +379 -379
- package/lib/display/Sprite.ts +165 -165
- package/lib/display/TextField.ts +3958 -3958
- package/lib/display/TextSprite.ts +22 -22
- package/lib/elements/SkyboxElements.ts +141 -141
- package/lib/errors/CastError.ts +6 -6
- package/lib/events/CameraEvent.ts +29 -29
- package/lib/events/FocusEvent.ts +69 -69
- package/lib/events/KeyboardEvent.ts +40 -40
- package/lib/events/MouseEvent.ts +147 -287
- package/lib/events/PointerEvent.ts +146 -0
- package/lib/events/ResizeEvent.ts +31 -31
- package/lib/events/TextfieldEvent.ts +28 -28
- package/lib/events/TouchEvent.ts +101 -0
- package/lib/factories/DefaultSceneGraphFactory.ts +56 -56
- package/lib/factories/ISceneGraphFactory.ts +28 -28
- package/lib/image/SceneImage2D.ts +1020 -1020
- package/lib/managers/DefaultFontManager.ts +124 -124
- package/lib/managers/DeviceFontManager.ts +55 -55
- package/lib/managers/FrameScriptManager.ts +431 -431
- package/lib/managers/IInputRecorder.ts +2 -2
- package/lib/managers/MouseManager.ts +944 -882
- package/lib/prefabs/PrefabBase.ts +47 -47
- package/lib/prefabs/PrimitiveCapsulePrefab.ts +286 -286
- package/lib/prefabs/PrimitiveConePrefab.ts +37 -37
- package/lib/prefabs/PrimitiveCubePrefab.ts +630 -630
- package/lib/prefabs/PrimitiveCylinderPrefab.ts +657 -657
- package/lib/prefabs/PrimitivePlanePrefab.ts +352 -352
- package/lib/prefabs/PrimitivePolygonPrefab.ts +53 -53
- package/lib/prefabs/PrimitivePrefabBase.ts +177 -177
- package/lib/prefabs/PrimitiveSpherePrefab.ts +336 -336
- package/lib/prefabs/PrimitiveTorusPrefab.ts +282 -282
- package/lib/text/AntiAliasType.ts +24 -24
- package/lib/text/BitmapFontChar.ts +53 -53
- package/lib/text/BitmapFontTable.ts +232 -232
- package/lib/text/FNTGenerator.ts +100 -100
- package/lib/text/FNTGeneratorCanvas.ts +287 -287
- package/lib/text/FNTGeneratrorBase.ts +10 -10
- package/lib/text/Font.ts +114 -114
- package/lib/text/FontLookUpMode.ts +5 -5
- package/lib/text/FontStyleName.ts +6 -6
- package/lib/text/GridFitType.ts +32 -32
- package/lib/text/HTMLTextProcessor.ts +418 -418
- package/lib/text/IFontTable.ts +17 -17
- package/lib/text/TesselatedFontChar.ts +80 -80
- package/lib/text/TesselatedFontTable.ts +1221 -1221
- package/lib/text/TextFieldAutoSize.ts +30 -30
- package/lib/text/TextFieldType.ts +21 -21
- package/lib/text/TextFormat.ts +601 -601
- package/lib/text/TextFormatAlign.ts +28 -28
- package/lib/text/TextInteractionMode.ts +21 -21
- package/lib/text/TextLineMetrics.ts +74 -74
- package/lib/text/TextShape.ts +90 -90
- package/lib/tools/Merge.ts +311 -311
- package/lib/utils/Cast.ts +304 -304
- package/package.json +74 -74
- package/rollup.config.js +33 -33
- package/scripts/build.sh +2 -2
- package/scripts/gendocs.sh +14 -14
- package/scripts/genexamples.sh +14 -14
- package/scripts/genfull.sh +14 -14
- package/system.config.js +51 -51
- package/tsconfig.json +18 -18
|
@@ -1,603 +1,603 @@
|
|
|
1
|
-
import { __extends } from "tslib";
|
|
2
|
-
import { AssetLibraryBundle, Loader, AssetEvent, URLLoaderEvent, LoaderEvent, ParserEvent } from '@awayjs/core';
|
|
3
|
-
import { DisplayObjectContainer } from './DisplayObjectContainer';
|
|
4
|
-
/**
|
|
5
|
-
* The LoaderContainer class is used to load SWF files or image(JPG, PNG, or GIF)
|
|
6
|
-
* files. Use the <code>load()</code> method to initiate loading. The loaded
|
|
7
|
-
* display object is added as a child of the LoaderContainer object.
|
|
8
|
-
*
|
|
9
|
-
* <p>Use the URLLoader class to load text or binary data.</p>
|
|
10
|
-
*
|
|
11
|
-
* <p>The LoaderContainer class overrides the following methods that it inherits,
|
|
12
|
-
* because a LoaderContainer object can only have one child display object - the
|
|
13
|
-
* display object that it loads. Calling the following methods throws an
|
|
14
|
-
* exception: <code>addChild()</code>, <code>addChildAt()</code>,
|
|
15
|
-
* <code>removeChild()</code>, <code>removeChildAt()</code>, and
|
|
16
|
-
* <code>setChildIndex()</code>. To remove a loaded display object, you must
|
|
17
|
-
* remove the <i>LoaderContainer</i> object from its parent DisplayObjectContainer
|
|
18
|
-
* child array. </p>
|
|
19
|
-
*
|
|
20
|
-
* <p><b>Note:</b> The ActionScript 2.0 MovieClipLoader and LoadVars classes
|
|
21
|
-
* are not used in ActionScript 3.0. The LoaderContainer and URLLoader classes replace
|
|
22
|
-
* them.</p>
|
|
23
|
-
*
|
|
24
|
-
* <p>When you use the LoaderContainer class, consider the Flash Player and Adobe AIR
|
|
25
|
-
* security model: </p>
|
|
26
|
-
*
|
|
27
|
-
* <ul>
|
|
28
|
-
* <li>You can load content from any accessible source. </li>
|
|
29
|
-
* <li>Loading is not allowed if the calling SWF file is in a network
|
|
30
|
-
* sandbox and the file to be loaded is local. </li>
|
|
31
|
-
* <li>If the loaded content is a SWF file written with ActionScript 3.0, it
|
|
32
|
-
* cannot be cross-scripted by a SWF file in another security sandbox unless
|
|
33
|
-
* that cross-scripting arrangement was approved through a call to the
|
|
34
|
-
* <code>System.allowDomain()</code> or the
|
|
35
|
-
* <code>System.allowInsecureDomain()</code> method in the loaded content
|
|
36
|
-
* file.</li>
|
|
37
|
-
* <li>If the loaded content is an AVM1 SWF file(written using ActionScript
|
|
38
|
-
* 1.0 or 2.0), it cannot be cross-scripted by an AVM2 SWF file(written using
|
|
39
|
-
* ActionScript 3.0). However, you can communicate between the two SWF files
|
|
40
|
-
* by using the LocalConnection class.</li>
|
|
41
|
-
* <li>If the loaded content is an image, its data cannot be accessed by a
|
|
42
|
-
* SWF file outside of the security sandbox, unless the domain of that SWF
|
|
43
|
-
* file was included in a URL policy file at the origin domain of the
|
|
44
|
-
* image.</li>
|
|
45
|
-
* <li>Movie clips in the local-with-file-system sandbox cannot script movie
|
|
46
|
-
* clips in the local-with-networking sandbox, and the reverse is also
|
|
47
|
-
* prevented. </li>
|
|
48
|
-
* <li>You cannot connect to commonly reserved ports. For a complete list of
|
|
49
|
-
* blocked ports, see "Restricting Networking APIs" in the <i>ActionScript 3.0
|
|
50
|
-
* Developer's Guide</i>. </li>
|
|
51
|
-
* </ul>
|
|
52
|
-
*
|
|
53
|
-
* <p>However, in AIR, content in the <code>application</code> security
|
|
54
|
-
* sandbox(content installed with the AIR application) are not restricted by
|
|
55
|
-
* these security limitations.</p>
|
|
56
|
-
*
|
|
57
|
-
* <p>For more information related to security, see the Flash Player Developer
|
|
58
|
-
* Center Topic: <a href="http://www.adobe.com/go/devnet_security_en"
|
|
59
|
-
* scope="external">Security</a>.</p>
|
|
60
|
-
*
|
|
61
|
-
* <p>When loading a SWF file from an untrusted source(such as a domain other
|
|
62
|
-
* than that of the LoaderContainer object's root SWF file), you may want to define a
|
|
63
|
-
* mask for the LoaderContainer object, to prevent the loaded content(which is a child
|
|
64
|
-
* of the LoaderContainer object) from drawing to portions of the Stage outside of that
|
|
65
|
-
* mask, as shown in the following code:</p>
|
|
66
|
-
*/
|
|
67
|
-
var LoaderContainer = /** @class */ (function (_super) {
|
|
68
|
-
__extends(LoaderContainer, _super);
|
|
69
|
-
/**
|
|
70
|
-
* Creates a Loader object that you can use to load files, such as SWF, JPEG,
|
|
71
|
-
* GIF, or PNG files. Call the <code>load()</code> method to load the asset
|
|
72
|
-
* as a child of the Loader instance. You can then add the Loader object to
|
|
73
|
-
* the display list(for instance, by using the <code>addChild()</code>
|
|
74
|
-
* method of a DisplayObjectContainer instance). The asset appears on the
|
|
75
|
-
* Stage as it loads.
|
|
76
|
-
*
|
|
77
|
-
* <p>You can also use a Loader instance "offlist," that is without adding it
|
|
78
|
-
* to a display object container on the display list. In this mode, the
|
|
79
|
-
* Loader instance might be used to load a SWF file that contains additional
|
|
80
|
-
* modules of an application. </p>
|
|
81
|
-
*
|
|
82
|
-
* <p>To detect when the SWF file is finished loading, you can use the events
|
|
83
|
-
* of the LoaderInfo object associated with the
|
|
84
|
-
* <code>contentLoaderInfo</code> property of the Loader object. At that
|
|
85
|
-
* point, the code in the module SWF file can be executed to initialize and
|
|
86
|
-
* start the module. In the offlist mode, a Loader instance might also be
|
|
87
|
-
* used to load a SWF file that contains components or media assets. Again,
|
|
88
|
-
* you can use the LoaderInfo object event notifications to detect when the
|
|
89
|
-
* components are finished loading. At that point, the application can start
|
|
90
|
-
* using the components and media assets in the library of the SWF file by
|
|
91
|
-
* instantiating the ActionScript 3.0 classes that represent those components
|
|
92
|
-
* and assets.</p>
|
|
93
|
-
*
|
|
94
|
-
* <p>To determine the status of a Loader object, monitor the following
|
|
95
|
-
* events that the LoaderInfo object associated with the
|
|
96
|
-
* <code>contentLoaderInfo</code> property of the Loader object:</p>
|
|
97
|
-
*
|
|
98
|
-
* <ul>
|
|
99
|
-
* <li>The <code>open</code> event is dispatched when loading begins.</li>
|
|
100
|
-
* <li>The <code>ioError</code> or <code>securityError</code> event is
|
|
101
|
-
* dispatched if the file cannot be loaded or if an error occured during the
|
|
102
|
-
* load process. </li>
|
|
103
|
-
* <li>The <code>progress</code> event fires continuously while the file is
|
|
104
|
-
* being loaded.</li>
|
|
105
|
-
* <li>The <code>complete</code> event is dispatched when a file completes
|
|
106
|
-
* downloading, but before the loaded movie clip's methods and properties are
|
|
107
|
-
* available. </li>
|
|
108
|
-
* <li>The <code>init</code> event is dispatched after the properties and
|
|
109
|
-
* methods of the loaded SWF file are accessible, so you can begin
|
|
110
|
-
* manipulating the loaded SWF file. This event is dispatched before the
|
|
111
|
-
* <code>complete</code> handler. In streaming SWF files, the
|
|
112
|
-
* <code>init</code> event can occur significantly earlier than the
|
|
113
|
-
* <code>complete</code> event. For most purposes, use the <code>init</code>
|
|
114
|
-
* handler.</li>
|
|
115
|
-
* </ul>
|
|
116
|
-
*/
|
|
117
|
-
function LoaderContainer(useAssetLibrary, assetLibraryId) {
|
|
118
|
-
var _a;
|
|
119
|
-
if (useAssetLibrary === void 0) { useAssetLibrary = true; }
|
|
120
|
-
if (assetLibraryId === void 0) { assetLibraryId = null; }
|
|
121
|
-
var _this = _super.call(this) || this;
|
|
122
|
-
_this._useAssetLib = useAssetLibrary;
|
|
123
|
-
_this._assetLibId = assetLibraryId;
|
|
124
|
-
_this._onLoaderStartDelegate = function (event) { return _this._onLoaderStart(event); };
|
|
125
|
-
_this._onLoadProgressDelegate = function (event) { return _this._onLoadProgress(event); };
|
|
126
|
-
_this._onLoadCompleteDelegate = function (event) { return _this._onLoadComplete(event); };
|
|
127
|
-
_this._onAssetCompleteDelegate = function (event) { return _this._onAssetComplete(event); };
|
|
128
|
-
_this._onLoaderCompleteDelegate = function (event) { return _this._onLoaderComplete(event); };
|
|
129
|
-
_this._onLoadErrorDelegate = function (event) { return _this._onLoadError(event); };
|
|
130
|
-
_this._onParseErrorDelegate = function (event) { return _this._onParseError(event); };
|
|
131
|
-
_this._errorDelegateSelector = (_a = {},
|
|
132
|
-
_a[URLLoaderEvent.LOAD_ERROR] = _this._onLoadErrorDelegate,
|
|
133
|
-
_a[ParserEvent.PARSE_ERROR] = _this._onParseErrorDelegate,
|
|
134
|
-
_a);
|
|
135
|
-
return _this;
|
|
136
|
-
}
|
|
137
|
-
Object.defineProperty(LoaderContainer.prototype, "content", {
|
|
138
|
-
/**
|
|
139
|
-
* Contains the root display object of the SWF file or image(JPG, PNG, or
|
|
140
|
-
* GIF) file that was loaded by using the <code>load()</code> or
|
|
141
|
-
* <code>loadBytes()</code> methods.
|
|
142
|
-
*
|
|
143
|
-
* @throws SecurityError The loaded SWF file or image file belongs to a
|
|
144
|
-
* security sandbox to which you do not have access.
|
|
145
|
-
* For a loaded SWF file, you can avoid this situation
|
|
146
|
-
* by having the file call the
|
|
147
|
-
* <code>Security.allowDomain()</code> method or by
|
|
148
|
-
* having the loading file specify a
|
|
149
|
-
* <code>loaderContext</code> parameter with its
|
|
150
|
-
* <code>securityDomain</code> property set to
|
|
151
|
-
* <code>SecurityDomain.currentDomain</code> when you
|
|
152
|
-
* call the <code>load()</code> or
|
|
153
|
-
* <code>loadBytes()</code> method.
|
|
154
|
-
*/
|
|
155
|
-
get: function () {
|
|
156
|
-
return this._content;
|
|
157
|
-
},
|
|
158
|
-
enumerable: false,
|
|
159
|
-
configurable: true
|
|
160
|
-
});
|
|
161
|
-
Object.defineProperty(LoaderContainer.prototype, "contentLoader", {
|
|
162
|
-
/**
|
|
163
|
-
*
|
|
164
|
-
*/
|
|
165
|
-
get: function () {
|
|
166
|
-
return this._contentLoader;
|
|
167
|
-
},
|
|
168
|
-
enumerable: false,
|
|
169
|
-
configurable: true
|
|
170
|
-
});
|
|
171
|
-
/**
|
|
172
|
-
* Special addEventListener case for <code>
|
|
173
|
-
* URLLoaderEvent.LOAD_ERROR</code> and <code>ype == ParserEvent.PARSE_ERROR</code>
|
|
174
|
-
*
|
|
175
|
-
* @param type
|
|
176
|
-
* @param listener
|
|
177
|
-
*/
|
|
178
|
-
LoaderContainer.prototype.addEventListener = function (type, listener) {
|
|
179
|
-
if (this._contentLoader && type == URLLoaderEvent.LOAD_ERROR || type == ParserEvent.PARSE_ERROR)
|
|
180
|
-
this._contentLoader.addEventListener(type, this._errorDelegateSelector[type]);
|
|
181
|
-
_super.prototype.addEventListener.call(this, type, listener);
|
|
182
|
-
};
|
|
183
|
-
/**
|
|
184
|
-
* Special removeEventListener case for <code>
|
|
185
|
-
* URLLoaderEvent.LOAD_ERROR</code> and <code>ype == ParserEvent.PARSE_ERROR</code>
|
|
186
|
-
*
|
|
187
|
-
* @param type
|
|
188
|
-
* @param listener
|
|
189
|
-
*/
|
|
190
|
-
LoaderContainer.prototype.removeEventListener = function (type, listener) {
|
|
191
|
-
if (this._contentLoader && type == URLLoaderEvent.LOAD_ERROR || type == ParserEvent.PARSE_ERROR)
|
|
192
|
-
this._contentLoader.removeEventListener(type, this._errorDelegateSelector[type]);
|
|
193
|
-
_super.prototype.removeEventListener.call(this, type, listener);
|
|
194
|
-
};
|
|
195
|
-
/**
|
|
196
|
-
* Cancels a <code>load()</code> method operation that is currently in
|
|
197
|
-
* progress for the Loader instance.
|
|
198
|
-
*
|
|
199
|
-
*/
|
|
200
|
-
LoaderContainer.prototype.close = function () {
|
|
201
|
-
if (!this._contentLoader)
|
|
202
|
-
return;
|
|
203
|
-
if (this._useAssetLib)
|
|
204
|
-
AssetLibraryBundle.getInstance(this._assetLibId).stopLoader(this._contentLoader);
|
|
205
|
-
this._disposeLoader();
|
|
206
|
-
};
|
|
207
|
-
/**
|
|
208
|
-
* Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file into an
|
|
209
|
-
* object that is a child of this Loader object. If you load an animated GIF
|
|
210
|
-
* file, only the first frame is displayed. As the Loader object can contain
|
|
211
|
-
* only a single child, issuing a subsequent <code>load()</code> request
|
|
212
|
-
* terminates the previous request, if still pending, and commences a new
|
|
213
|
-
* load.
|
|
214
|
-
*
|
|
215
|
-
* <p><b>Note</b>: In AIR 1.5 and Flash Player 10, the maximum size for a
|
|
216
|
-
* loaded image is 8,191 pixels in width or height, and the total number of
|
|
217
|
-
* pixels cannot exceed 16,777,215 pixels.(So, if an loaded image is 8,191
|
|
218
|
-
* pixels wide, it can only be 2,048 pixels high.) In Flash Player 9 and
|
|
219
|
-
* earlier and AIR 1.1 and earlier, the limitation is 2,880 pixels in height
|
|
220
|
-
* and 2,880 pixels in width.</p>
|
|
221
|
-
*
|
|
222
|
-
* <p>A SWF file or image loaded into a Loader object inherits the position,
|
|
223
|
-
* rotation, and scale properties of the parent display objects of the Loader
|
|
224
|
-
* object. </p>
|
|
225
|
-
*
|
|
226
|
-
* <p>Use the <code>unload()</code> method to remove movies or images loaded
|
|
227
|
-
* with this method, or to cancel a load operation that is in progress.</p>
|
|
228
|
-
*
|
|
229
|
-
* <p>You can prevent a SWF file from using this method by setting the
|
|
230
|
-
* <code>allowNetworking</code> parameter of the the <code>object</code> and
|
|
231
|
-
* <code>embed</code> tags in the HTML page that contains the SWF
|
|
232
|
-
* content.</p>
|
|
233
|
-
*
|
|
234
|
-
* <p>When you use this method, consider the Flash Player security model,
|
|
235
|
-
* which is described in the Loader class description. </p>
|
|
236
|
-
*
|
|
237
|
-
* <p> In Flash Player 10 and later, if you use a multipart Content-Type(for
|
|
238
|
-
* example "multipart/form-data") that contains an upload(indicated by a
|
|
239
|
-
* "filename" parameter in a "content-disposition" header within the POST
|
|
240
|
-
* body), the POST operation is subject to the security rules applied to
|
|
241
|
-
* uploads:</p>
|
|
242
|
-
*
|
|
243
|
-
* <ul>
|
|
244
|
-
* <li>The POST operation must be performed in response to a user-initiated
|
|
245
|
-
* action, such as a mouse click or key press.</li>
|
|
246
|
-
* <li>If the POST operation is cross-domain(the POST target is not on the
|
|
247
|
-
* same server as the SWF file that is sending the POST request), the target
|
|
248
|
-
* server must provide a URL policy file that permits cross-domain
|
|
249
|
-
* access.</li>
|
|
250
|
-
* </ul>
|
|
251
|
-
*
|
|
252
|
-
* <p>Also, for any multipart Content-Type, the syntax must be valid
|
|
253
|
-
* (according to the RFC2046 standard). If the syntax appears to be invalid,
|
|
254
|
-
* the POST operation is subject to the security rules applied to
|
|
255
|
-
* uploads.</p>
|
|
256
|
-
*
|
|
257
|
-
* <p>For more information related to security, see the Flash Player
|
|
258
|
-
* Developer Center Topic: <a
|
|
259
|
-
* href="http://www.adobe.com/go/devnet_security_en"
|
|
260
|
-
* scope="external">Security</a>.</p>
|
|
261
|
-
*
|
|
262
|
-
* @param request The absolute or relative URL of the SWF, JPEG, GIF, or PNG
|
|
263
|
-
* file to be loaded. A relative path must be relative to the
|
|
264
|
-
* main SWF file. Absolute URLs must include the protocol
|
|
265
|
-
* reference, such as http:// or file:///. Filenames cannot
|
|
266
|
-
* include disk drive specifications.
|
|
267
|
-
* @param context A LoaderContext object, which has properties that define
|
|
268
|
-
* the following:
|
|
269
|
-
* <ul>
|
|
270
|
-
* <li>Whether or not to check for the existence of a policy
|
|
271
|
-
* file upon loading the object</li>
|
|
272
|
-
* <li>The ApplicationDomain for the loaded object</li>
|
|
273
|
-
* <li>The SecurityDomain for the loaded object</li>
|
|
274
|
-
* <li>The ImageDecodingPolicy for the loaded image
|
|
275
|
-
* object</li>
|
|
276
|
-
* </ul>
|
|
277
|
-
*
|
|
278
|
-
* <p>If the <code>context</code> parameter is not specified
|
|
279
|
-
* or refers to a null object, the loaded content remains in
|
|
280
|
-
* its own security domain.</p>
|
|
281
|
-
*
|
|
282
|
-
* <p>For complete details, see the description of the
|
|
283
|
-
* properties in the <a
|
|
284
|
-
* href="../system/LoaderContext.html">LoaderContext</a>
|
|
285
|
-
* class.</p>
|
|
286
|
-
* @param ns An optional namespace string under which the file is to be
|
|
287
|
-
* loaded, allowing the differentiation of two resources with
|
|
288
|
-
* identical assets.
|
|
289
|
-
* @param parser An optional parser object for translating the loaded data
|
|
290
|
-
* into a usable resource. If not provided, Loader will
|
|
291
|
-
* attempt to auto-detect the file type.
|
|
292
|
-
* @throws IOError The <code>digest</code> property of the
|
|
293
|
-
* <code>request</code> object is not
|
|
294
|
-
* <code>null</code>. You should only set the
|
|
295
|
-
* <code>digest</code> property of a URLRequest
|
|
296
|
-
* object when calling the
|
|
297
|
-
* <code>URLLoader.load()</code> method when
|
|
298
|
-
* loading a SWZ file(an Adobe platform
|
|
299
|
-
* component).
|
|
300
|
-
* @throws IllegalOperationError If the <code>requestedContentParent</code>
|
|
301
|
-
* property of the <code>context</code>
|
|
302
|
-
* parameter is a <code>Loader</code>.
|
|
303
|
-
* @throws IllegalOperationError If the <code>LoaderContext.parameters</code>
|
|
304
|
-
* parameter is set to non-null and has some
|
|
305
|
-
* values which are not Strings.
|
|
306
|
-
* @throws SecurityError The value of
|
|
307
|
-
* <code>LoaderContext.securityDomain</code>
|
|
308
|
-
* must be either <code>null</code> or
|
|
309
|
-
* <code>SecurityDomain.currentDomain</code>.
|
|
310
|
-
* This reflects the fact that you can only
|
|
311
|
-
* place the loaded media in its natural
|
|
312
|
-
* security sandbox or your own(the latter
|
|
313
|
-
* requires a policy file).
|
|
314
|
-
* @throws SecurityError Local SWF files may not set
|
|
315
|
-
* LoaderContext.securityDomain to anything
|
|
316
|
-
* other than <code>null</code>. It is not
|
|
317
|
-
* permitted to import non-local media into a
|
|
318
|
-
* local sandbox, or to place other local media
|
|
319
|
-
* in anything other than its natural sandbox.
|
|
320
|
-
* @throws SecurityError You cannot connect to commonly reserved
|
|
321
|
-
* ports. For a complete list of blocked ports,
|
|
322
|
-
* see "Restricting Networking APIs" in the
|
|
323
|
-
* <i>ActionScript 3.0 Developer's Guide</i>.
|
|
324
|
-
* @throws SecurityError If the <code>applicationDomain</code> or
|
|
325
|
-
* <code>securityDomain</code> properties of
|
|
326
|
-
* the <code>context</code> parameter are from
|
|
327
|
-
* a disallowed domain.
|
|
328
|
-
* @throws SecurityError If a local SWF file is attempting to use the
|
|
329
|
-
* <code>securityDomain</code> property of the
|
|
330
|
-
* <code>context</code> parameter.
|
|
331
|
-
* @event asyncError Dispatched by the <code>contentLoaderInfo</code>
|
|
332
|
-
* object if the
|
|
333
|
-
* <code>LoaderContext.requestedContentParent</code>
|
|
334
|
-
* property has been specified and it is not possible to
|
|
335
|
-
* add the loaded content as a child to the specified
|
|
336
|
-
* DisplayObjectContainer. This could happen if the
|
|
337
|
-
* loaded content is a
|
|
338
|
-
* <code>flash.display.AVM1Movie</code> or if the
|
|
339
|
-
* <code>addChild()</code> call to the
|
|
340
|
-
* requestedContentParent throws an error.
|
|
341
|
-
* @event complete Dispatched by the <code>contentLoaderInfo</code>
|
|
342
|
-
* object when the file has completed loading. The
|
|
343
|
-
* <code>complete</code> event is always dispatched
|
|
344
|
-
* after the <code>init</code> event.
|
|
345
|
-
* @event httpStatus Dispatched by the <code>contentLoaderInfo</code>
|
|
346
|
-
* object when a network request is made over HTTP and
|
|
347
|
-
* Flash Player can detect the HTTP status code.
|
|
348
|
-
* @event init Dispatched by the <code>contentLoaderInfo</code>
|
|
349
|
-
* object when the properties and methods of the loaded
|
|
350
|
-
* SWF file are accessible. The <code>init</code> event
|
|
351
|
-
* always precedes the <code>complete</code> event.
|
|
352
|
-
* @event ioError Dispatched by the <code>contentLoaderInfo</code>
|
|
353
|
-
* object when an input or output error occurs that
|
|
354
|
-
* causes a load operation to fail.
|
|
355
|
-
* @event open Dispatched by the <code>contentLoaderInfo</code>
|
|
356
|
-
* object when the loading operation starts.
|
|
357
|
-
* @event progress Dispatched by the <code>contentLoaderInfo</code>
|
|
358
|
-
* object as data is received while load operation
|
|
359
|
-
* progresses.
|
|
360
|
-
* @event securityError Dispatched by the <code>contentLoaderInfo</code>
|
|
361
|
-
* object if a SWF file in the local-with-filesystem
|
|
362
|
-
* sandbox attempts to load content in the
|
|
363
|
-
* local-with-networking sandbox, or vice versa.
|
|
364
|
-
* @event securityError Dispatched by the <code>contentLoaderInfo</code>
|
|
365
|
-
* object if the
|
|
366
|
-
* <code>LoaderContext.requestedContentParent</code>
|
|
367
|
-
* property has been specified and the security sandbox
|
|
368
|
-
* of the
|
|
369
|
-
* <code>LoaderContext.requestedContentParent</code>
|
|
370
|
-
* does not have access to the loaded SWF.
|
|
371
|
-
* @event unload Dispatched by the <code>contentLoaderInfo</code>
|
|
372
|
-
* object when a loaded object is removed.
|
|
373
|
-
*/
|
|
374
|
-
LoaderContainer.prototype.load = function (request, context, ns, parser) {
|
|
375
|
-
if (context === void 0) { context = null; }
|
|
376
|
-
if (ns === void 0) { ns = null; }
|
|
377
|
-
if (parser === void 0) { parser = null; }
|
|
378
|
-
this._getLoader().load(request, context, ns, parser);
|
|
379
|
-
};
|
|
380
|
-
/**
|
|
381
|
-
* Loads from binary data stored in a ByteArray object.
|
|
382
|
-
*
|
|
383
|
-
* <p>The <code>loadBytes()</code> method is asynchronous. You must wait for
|
|
384
|
-
* the "init" event before accessing the properties of a loaded object.</p>
|
|
385
|
-
*
|
|
386
|
-
* <p>When you use this method, consider the Flash Player security model,
|
|
387
|
-
* which is described in the Loader class description. </p>
|
|
388
|
-
*
|
|
389
|
-
* @param bytes A ByteArray object. The contents of the ByteArray can be
|
|
390
|
-
* any of the file formats supported by the Loader class: SWF,
|
|
391
|
-
* GIF, JPEG, or PNG.
|
|
392
|
-
* @param context A LoaderContext object. Only the
|
|
393
|
-
* <code>applicationDomain</code> property of the
|
|
394
|
-
* LoaderContext object applies; the
|
|
395
|
-
* <code>checkPolicyFile</code> and
|
|
396
|
-
* <code>securityDomain</code> properties of the LoaderContext
|
|
397
|
-
* object do not apply.
|
|
398
|
-
*
|
|
399
|
-
* <p>If the <code>context</code> parameter is not specified
|
|
400
|
-
* or refers to a null object, the content is loaded into the
|
|
401
|
-
* current security domain - a process referred to as "import
|
|
402
|
-
* loading" in Flash Player security documentation.
|
|
403
|
-
* Specifically, if the loading SWF file trusts the remote SWF
|
|
404
|
-
* by incorporating the remote SWF into its code, then the
|
|
405
|
-
* loading SWF can import it directly into its own security
|
|
406
|
-
* domain.</p>
|
|
407
|
-
*
|
|
408
|
-
* <p>For more information related to security, see the Flash
|
|
409
|
-
* Player Developer Center Topic: <a
|
|
410
|
-
* href="http://www.adobe.com/go/devnet_security_en"
|
|
411
|
-
* scope="external">Security</a>.</p>
|
|
412
|
-
* @throws ArgumentError If the <code>length</code> property of the
|
|
413
|
-
* ByteArray object is not greater than 0.
|
|
414
|
-
* @throws IllegalOperationError If the <code>checkPolicyFile</code> or
|
|
415
|
-
* <code>securityDomain</code> property of the
|
|
416
|
-
* <code>context</code> parameter are non-null.
|
|
417
|
-
* @throws IllegalOperationError If the <code>requestedContentParent</code>
|
|
418
|
-
* property of the <code>context</code>
|
|
419
|
-
* parameter is a <code>Loader</code>.
|
|
420
|
-
* @throws IllegalOperationError If the <code>LoaderContext.parameters</code>
|
|
421
|
-
* parameter is set to non-null and has some
|
|
422
|
-
* values which are not Strings.
|
|
423
|
-
* @throws SecurityError If the provided
|
|
424
|
-
* <code>applicationDomain</code> property of
|
|
425
|
-
* the <code>context</code> property is from a
|
|
426
|
-
* disallowed domain.
|
|
427
|
-
* @throws SecurityError You cannot connect to commonly reserved
|
|
428
|
-
* ports. For a complete list of blocked ports,
|
|
429
|
-
* see "Restricting Networking APIs" in the
|
|
430
|
-
* <i>ActionScript 3.0 Developer's Guide</i>.
|
|
431
|
-
* @event asyncError Dispatched by the <code>contentLoaderInfo</code>
|
|
432
|
-
* object if the
|
|
433
|
-
* <code>LoaderContext.requestedContentParent</code>
|
|
434
|
-
* property has been specified and it is not possible to
|
|
435
|
-
* add the loaded content as a child to the specified
|
|
436
|
-
* DisplayObjectContainer. This could happen if the
|
|
437
|
-
* loaded content is a
|
|
438
|
-
* <code>flash.display.AVM1Movie</code> or if the
|
|
439
|
-
* <code>addChild()</code> call to the
|
|
440
|
-
* requestedContentParent throws an error.
|
|
441
|
-
* @event complete Dispatched by the <code>contentLoaderInfo</code>
|
|
442
|
-
* object when the operation is complete. The
|
|
443
|
-
* <code>complete</code> event is always dispatched
|
|
444
|
-
* after the <code>init</code> event.
|
|
445
|
-
* @event init Dispatched by the <code>contentLoaderInfo</code>
|
|
446
|
-
* object when the properties and methods of the loaded
|
|
447
|
-
* data are accessible. The <code>init</code> event
|
|
448
|
-
* always precedes the <code>complete</code> event.
|
|
449
|
-
* @event ioError Dispatched by the <code>contentLoaderInfo</code>
|
|
450
|
-
* object when the runtime cannot parse the data in the
|
|
451
|
-
* byte array.
|
|
452
|
-
* @event open Dispatched by the <code>contentLoaderInfo</code>
|
|
453
|
-
* object when the operation starts.
|
|
454
|
-
* @event progress Dispatched by the <code>contentLoaderInfo</code>
|
|
455
|
-
* object as data is transfered in memory.
|
|
456
|
-
* @event securityError Dispatched by the <code>contentLoaderInfo</code>
|
|
457
|
-
* object if the
|
|
458
|
-
* <code>LoaderContext.requestedContentParent</code>
|
|
459
|
-
* property has been specified and the security sandbox
|
|
460
|
-
* of the
|
|
461
|
-
* <code>LoaderContext.requestedContentParent</code>
|
|
462
|
-
* does not have access to the loaded SWF.
|
|
463
|
-
* @event unload Dispatched by the <code>contentLoaderInfo</code>
|
|
464
|
-
* object when a loaded object is removed.
|
|
465
|
-
*/
|
|
466
|
-
LoaderContainer.prototype.loadData = function (data, context, ns, parser) {
|
|
467
|
-
if (context === void 0) { context = null; }
|
|
468
|
-
if (ns === void 0) { ns = null; }
|
|
469
|
-
if (parser === void 0) { parser = null; }
|
|
470
|
-
this._getLoader().loadData(data, '', context, ns, parser);
|
|
471
|
-
};
|
|
472
|
-
LoaderContainer.prototype._getLoader = function () {
|
|
473
|
-
if (this._contentLoader)
|
|
474
|
-
this.close();
|
|
475
|
-
this._contentLoader =
|
|
476
|
-
(this._useAssetLib) ? AssetLibraryBundle.getInstance(this._assetLibId).getLoader() : new Loader();
|
|
477
|
-
this._contentLoader.addEventListener(LoaderEvent.LOADER_START, this._onLoaderStartDelegate);
|
|
478
|
-
this._contentLoader.addEventListener(URLLoaderEvent.LOAD_PROGRESS, this._onLoadProgressDelegate);
|
|
479
|
-
this._contentLoader.addEventListener(URLLoaderEvent.LOAD_COMPLETE, this._onLoadCompleteDelegate);
|
|
480
|
-
this._contentLoader.addEventListener(AssetEvent.ASSET_COMPLETE, this._onAssetCompleteDelegate);
|
|
481
|
-
this._contentLoader.addEventListener(LoaderEvent.LOADER_COMPLETE, this._onLoaderCompleteDelegate);
|
|
482
|
-
if (this.hasEventListener(URLLoaderEvent.LOAD_ERROR))
|
|
483
|
-
this._contentLoader.addEventListener(URLLoaderEvent.LOAD_ERROR, this._onLoadErrorDelegate);
|
|
484
|
-
if (this.hasEventListener(ParserEvent.PARSE_ERROR))
|
|
485
|
-
this._contentLoader.addEventListener(ParserEvent.PARSE_ERROR, this._onParseErrorDelegate);
|
|
486
|
-
return this._contentLoader;
|
|
487
|
-
};
|
|
488
|
-
LoaderContainer.prototype._disposeLoader = function () {
|
|
489
|
-
this._contentLoader.removeEventListener(LoaderEvent.LOADER_START, this._onLoaderStartDelegate);
|
|
490
|
-
this._contentLoader.removeEventListener(URLLoaderEvent.LOAD_PROGRESS, this._onLoadProgressDelegate);
|
|
491
|
-
this._contentLoader.removeEventListener(URLLoaderEvent.LOAD_COMPLETE, this._onLoadCompleteDelegate);
|
|
492
|
-
this._contentLoader.removeEventListener(AssetEvent.ASSET_COMPLETE, this._onAssetCompleteDelegate);
|
|
493
|
-
this._contentLoader.removeEventListener(LoaderEvent.LOADER_COMPLETE, this._onLoaderCompleteDelegate);
|
|
494
|
-
if (this.hasEventListener(URLLoaderEvent.LOAD_ERROR))
|
|
495
|
-
this._contentLoader.removeEventListener(URLLoaderEvent.LOAD_ERROR, this._onLoadErrorDelegate);
|
|
496
|
-
if (this.hasEventListener(ParserEvent.PARSE_ERROR))
|
|
497
|
-
this._contentLoader.removeEventListener(ParserEvent.PARSE_ERROR, this._onParseErrorDelegate);
|
|
498
|
-
if (!this._useAssetLib)
|
|
499
|
-
this._contentLoader.stop();
|
|
500
|
-
this._contentLoader = null;
|
|
501
|
-
};
|
|
502
|
-
/**
|
|
503
|
-
* Removes a child of this Loader object that was loaded by using the
|
|
504
|
-
* <code>load()</code> method. The <code>property</code> of the associated
|
|
505
|
-
* LoaderInfo object is reset to <code>null</code>. The child is not
|
|
506
|
-
* necessarily destroyed because other objects might have references to it;
|
|
507
|
-
* however, it is no longer a child of the Loader object.
|
|
508
|
-
*
|
|
509
|
-
* <p>As a best practice, before you unload a child SWF file, you should
|
|
510
|
-
* explicitly close any streams in the child SWF file's objects, such as
|
|
511
|
-
* LocalConnection, NetConnection, NetStream, and Sound objects. Otherwise,
|
|
512
|
-
* audio in the child SWF file might continue to play, even though the child
|
|
513
|
-
* SWF file was unloaded. To close streams in the child SWF file, add an
|
|
514
|
-
* event listener to the child that listens for the <code>unload</code>
|
|
515
|
-
* event. When the parent calls <code>Loader.unload()</code>, the
|
|
516
|
-
* <code>unload</code> event is dispatched to the child. The following code
|
|
517
|
-
* shows how you might do this:</p>
|
|
518
|
-
* <pre xml:space="preserve"> public closeAllStreams(evt:Event) {
|
|
519
|
-
* myNetStream.close(); mySound.close(); myNetConnection.close();
|
|
520
|
-
* myLocalConnection.close(); }
|
|
521
|
-
* myMovieClip.loaderInfo.addEventListener(Event.UNLOAD,
|
|
522
|
-
* closeAllStreams);</pre>
|
|
523
|
-
*
|
|
524
|
-
*/
|
|
525
|
-
LoaderContainer.prototype.unload = function () {
|
|
526
|
-
//TODO
|
|
527
|
-
};
|
|
528
|
-
/**
|
|
529
|
-
* Enables a specific parser.
|
|
530
|
-
* When no specific parser is set for a loading/parsing opperation,
|
|
531
|
-
* loader3d can autoselect the correct parser to use.
|
|
532
|
-
* A parser must have been enabled, to be considered when autoselecting the parser.
|
|
533
|
-
*
|
|
534
|
-
* @param parserClass The parser class to enable.
|
|
535
|
-
* @see away.parsers.Parsers
|
|
536
|
-
*/
|
|
537
|
-
LoaderContainer.enableParser = function (parserClass) {
|
|
538
|
-
Loader.enableParser(parserClass);
|
|
539
|
-
};
|
|
540
|
-
/**
|
|
541
|
-
* Enables a list of parsers.
|
|
542
|
-
* When no specific parser is set for a loading/parsing opperation,
|
|
543
|
-
* loader3d can autoselect the correct parser to use.
|
|
544
|
-
* A parser must have been enabled, to be considered when autoselecting the parser.
|
|
545
|
-
*
|
|
546
|
-
* @param parserClasses A Vector of parser classes to enable.
|
|
547
|
-
* @see away.parsers.Parsers
|
|
548
|
-
*/
|
|
549
|
-
LoaderContainer.enableParsers = function (parserClasses) {
|
|
550
|
-
Loader.enableParsers(parserClasses);
|
|
551
|
-
};
|
|
552
|
-
/**
|
|
553
|
-
* .
|
|
554
|
-
*/
|
|
555
|
-
LoaderContainer.prototype._onLoaderStart = function (event) {
|
|
556
|
-
this.dispatchEvent(event);
|
|
557
|
-
};
|
|
558
|
-
LoaderContainer.prototype._onLoadProgress = function (event) {
|
|
559
|
-
this.dispatchEvent(event);
|
|
560
|
-
};
|
|
561
|
-
LoaderContainer.prototype._onLoadComplete = function (event) {
|
|
562
|
-
this.dispatchEvent(event);
|
|
563
|
-
};
|
|
564
|
-
LoaderContainer.prototype._onAssetComplete = function (event) {
|
|
565
|
-
this.dispatchEvent(event);
|
|
566
|
-
};
|
|
567
|
-
/**
|
|
568
|
-
* Called when an error occurs during loading
|
|
569
|
-
*/
|
|
570
|
-
LoaderContainer.prototype._onLoadError = function (event) {
|
|
571
|
-
if (this.hasEventListener(URLLoaderEvent.LOAD_ERROR)) {
|
|
572
|
-
this.dispatchEvent(event);
|
|
573
|
-
return true;
|
|
574
|
-
}
|
|
575
|
-
else {
|
|
576
|
-
return false;
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
/**
|
|
580
|
-
* Called when a an error occurs during parsing
|
|
581
|
-
*/
|
|
582
|
-
LoaderContainer.prototype._onParseError = function (event) {
|
|
583
|
-
if (this.hasEventListener(ParserEvent.PARSE_ERROR)) {
|
|
584
|
-
this.dispatchEvent(event);
|
|
585
|
-
return true;
|
|
586
|
-
}
|
|
587
|
-
else {
|
|
588
|
-
return false;
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
/**
|
|
592
|
-
* Called when the resource and all of its dependencies was retrieved.
|
|
593
|
-
*/
|
|
594
|
-
LoaderContainer.prototype._onLoaderComplete = function (event) {
|
|
595
|
-
this._content = event.content;
|
|
596
|
-
if (this._content)
|
|
597
|
-
this.addChild(this._content);
|
|
598
|
-
this.dispatchEvent(event);
|
|
599
|
-
this._disposeLoader();
|
|
600
|
-
};
|
|
601
|
-
return LoaderContainer;
|
|
602
|
-
}(DisplayObjectContainer));
|
|
603
|
-
export { LoaderContainer };
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import { AssetLibraryBundle, Loader, AssetEvent, URLLoaderEvent, LoaderEvent, ParserEvent } from '@awayjs/core';
|
|
3
|
+
import { DisplayObjectContainer } from './DisplayObjectContainer';
|
|
4
|
+
/**
|
|
5
|
+
* The LoaderContainer class is used to load SWF files or image(JPG, PNG, or GIF)
|
|
6
|
+
* files. Use the <code>load()</code> method to initiate loading. The loaded
|
|
7
|
+
* display object is added as a child of the LoaderContainer object.
|
|
8
|
+
*
|
|
9
|
+
* <p>Use the URLLoader class to load text or binary data.</p>
|
|
10
|
+
*
|
|
11
|
+
* <p>The LoaderContainer class overrides the following methods that it inherits,
|
|
12
|
+
* because a LoaderContainer object can only have one child display object - the
|
|
13
|
+
* display object that it loads. Calling the following methods throws an
|
|
14
|
+
* exception: <code>addChild()</code>, <code>addChildAt()</code>,
|
|
15
|
+
* <code>removeChild()</code>, <code>removeChildAt()</code>, and
|
|
16
|
+
* <code>setChildIndex()</code>. To remove a loaded display object, you must
|
|
17
|
+
* remove the <i>LoaderContainer</i> object from its parent DisplayObjectContainer
|
|
18
|
+
* child array. </p>
|
|
19
|
+
*
|
|
20
|
+
* <p><b>Note:</b> The ActionScript 2.0 MovieClipLoader and LoadVars classes
|
|
21
|
+
* are not used in ActionScript 3.0. The LoaderContainer and URLLoader classes replace
|
|
22
|
+
* them.</p>
|
|
23
|
+
*
|
|
24
|
+
* <p>When you use the LoaderContainer class, consider the Flash Player and Adobe AIR
|
|
25
|
+
* security model: </p>
|
|
26
|
+
*
|
|
27
|
+
* <ul>
|
|
28
|
+
* <li>You can load content from any accessible source. </li>
|
|
29
|
+
* <li>Loading is not allowed if the calling SWF file is in a network
|
|
30
|
+
* sandbox and the file to be loaded is local. </li>
|
|
31
|
+
* <li>If the loaded content is a SWF file written with ActionScript 3.0, it
|
|
32
|
+
* cannot be cross-scripted by a SWF file in another security sandbox unless
|
|
33
|
+
* that cross-scripting arrangement was approved through a call to the
|
|
34
|
+
* <code>System.allowDomain()</code> or the
|
|
35
|
+
* <code>System.allowInsecureDomain()</code> method in the loaded content
|
|
36
|
+
* file.</li>
|
|
37
|
+
* <li>If the loaded content is an AVM1 SWF file(written using ActionScript
|
|
38
|
+
* 1.0 or 2.0), it cannot be cross-scripted by an AVM2 SWF file(written using
|
|
39
|
+
* ActionScript 3.0). However, you can communicate between the two SWF files
|
|
40
|
+
* by using the LocalConnection class.</li>
|
|
41
|
+
* <li>If the loaded content is an image, its data cannot be accessed by a
|
|
42
|
+
* SWF file outside of the security sandbox, unless the domain of that SWF
|
|
43
|
+
* file was included in a URL policy file at the origin domain of the
|
|
44
|
+
* image.</li>
|
|
45
|
+
* <li>Movie clips in the local-with-file-system sandbox cannot script movie
|
|
46
|
+
* clips in the local-with-networking sandbox, and the reverse is also
|
|
47
|
+
* prevented. </li>
|
|
48
|
+
* <li>You cannot connect to commonly reserved ports. For a complete list of
|
|
49
|
+
* blocked ports, see "Restricting Networking APIs" in the <i>ActionScript 3.0
|
|
50
|
+
* Developer's Guide</i>. </li>
|
|
51
|
+
* </ul>
|
|
52
|
+
*
|
|
53
|
+
* <p>However, in AIR, content in the <code>application</code> security
|
|
54
|
+
* sandbox(content installed with the AIR application) are not restricted by
|
|
55
|
+
* these security limitations.</p>
|
|
56
|
+
*
|
|
57
|
+
* <p>For more information related to security, see the Flash Player Developer
|
|
58
|
+
* Center Topic: <a href="http://www.adobe.com/go/devnet_security_en"
|
|
59
|
+
* scope="external">Security</a>.</p>
|
|
60
|
+
*
|
|
61
|
+
* <p>When loading a SWF file from an untrusted source(such as a domain other
|
|
62
|
+
* than that of the LoaderContainer object's root SWF file), you may want to define a
|
|
63
|
+
* mask for the LoaderContainer object, to prevent the loaded content(which is a child
|
|
64
|
+
* of the LoaderContainer object) from drawing to portions of the Stage outside of that
|
|
65
|
+
* mask, as shown in the following code:</p>
|
|
66
|
+
*/
|
|
67
|
+
var LoaderContainer = /** @class */ (function (_super) {
|
|
68
|
+
__extends(LoaderContainer, _super);
|
|
69
|
+
/**
|
|
70
|
+
* Creates a Loader object that you can use to load files, such as SWF, JPEG,
|
|
71
|
+
* GIF, or PNG files. Call the <code>load()</code> method to load the asset
|
|
72
|
+
* as a child of the Loader instance. You can then add the Loader object to
|
|
73
|
+
* the display list(for instance, by using the <code>addChild()</code>
|
|
74
|
+
* method of a DisplayObjectContainer instance). The asset appears on the
|
|
75
|
+
* Stage as it loads.
|
|
76
|
+
*
|
|
77
|
+
* <p>You can also use a Loader instance "offlist," that is without adding it
|
|
78
|
+
* to a display object container on the display list. In this mode, the
|
|
79
|
+
* Loader instance might be used to load a SWF file that contains additional
|
|
80
|
+
* modules of an application. </p>
|
|
81
|
+
*
|
|
82
|
+
* <p>To detect when the SWF file is finished loading, you can use the events
|
|
83
|
+
* of the LoaderInfo object associated with the
|
|
84
|
+
* <code>contentLoaderInfo</code> property of the Loader object. At that
|
|
85
|
+
* point, the code in the module SWF file can be executed to initialize and
|
|
86
|
+
* start the module. In the offlist mode, a Loader instance might also be
|
|
87
|
+
* used to load a SWF file that contains components or media assets. Again,
|
|
88
|
+
* you can use the LoaderInfo object event notifications to detect when the
|
|
89
|
+
* components are finished loading. At that point, the application can start
|
|
90
|
+
* using the components and media assets in the library of the SWF file by
|
|
91
|
+
* instantiating the ActionScript 3.0 classes that represent those components
|
|
92
|
+
* and assets.</p>
|
|
93
|
+
*
|
|
94
|
+
* <p>To determine the status of a Loader object, monitor the following
|
|
95
|
+
* events that the LoaderInfo object associated with the
|
|
96
|
+
* <code>contentLoaderInfo</code> property of the Loader object:</p>
|
|
97
|
+
*
|
|
98
|
+
* <ul>
|
|
99
|
+
* <li>The <code>open</code> event is dispatched when loading begins.</li>
|
|
100
|
+
* <li>The <code>ioError</code> or <code>securityError</code> event is
|
|
101
|
+
* dispatched if the file cannot be loaded or if an error occured during the
|
|
102
|
+
* load process. </li>
|
|
103
|
+
* <li>The <code>progress</code> event fires continuously while the file is
|
|
104
|
+
* being loaded.</li>
|
|
105
|
+
* <li>The <code>complete</code> event is dispatched when a file completes
|
|
106
|
+
* downloading, but before the loaded movie clip's methods and properties are
|
|
107
|
+
* available. </li>
|
|
108
|
+
* <li>The <code>init</code> event is dispatched after the properties and
|
|
109
|
+
* methods of the loaded SWF file are accessible, so you can begin
|
|
110
|
+
* manipulating the loaded SWF file. This event is dispatched before the
|
|
111
|
+
* <code>complete</code> handler. In streaming SWF files, the
|
|
112
|
+
* <code>init</code> event can occur significantly earlier than the
|
|
113
|
+
* <code>complete</code> event. For most purposes, use the <code>init</code>
|
|
114
|
+
* handler.</li>
|
|
115
|
+
* </ul>
|
|
116
|
+
*/
|
|
117
|
+
function LoaderContainer(useAssetLibrary, assetLibraryId) {
|
|
118
|
+
var _a;
|
|
119
|
+
if (useAssetLibrary === void 0) { useAssetLibrary = true; }
|
|
120
|
+
if (assetLibraryId === void 0) { assetLibraryId = null; }
|
|
121
|
+
var _this = _super.call(this) || this;
|
|
122
|
+
_this._useAssetLib = useAssetLibrary;
|
|
123
|
+
_this._assetLibId = assetLibraryId;
|
|
124
|
+
_this._onLoaderStartDelegate = function (event) { return _this._onLoaderStart(event); };
|
|
125
|
+
_this._onLoadProgressDelegate = function (event) { return _this._onLoadProgress(event); };
|
|
126
|
+
_this._onLoadCompleteDelegate = function (event) { return _this._onLoadComplete(event); };
|
|
127
|
+
_this._onAssetCompleteDelegate = function (event) { return _this._onAssetComplete(event); };
|
|
128
|
+
_this._onLoaderCompleteDelegate = function (event) { return _this._onLoaderComplete(event); };
|
|
129
|
+
_this._onLoadErrorDelegate = function (event) { return _this._onLoadError(event); };
|
|
130
|
+
_this._onParseErrorDelegate = function (event) { return _this._onParseError(event); };
|
|
131
|
+
_this._errorDelegateSelector = (_a = {},
|
|
132
|
+
_a[URLLoaderEvent.LOAD_ERROR] = _this._onLoadErrorDelegate,
|
|
133
|
+
_a[ParserEvent.PARSE_ERROR] = _this._onParseErrorDelegate,
|
|
134
|
+
_a);
|
|
135
|
+
return _this;
|
|
136
|
+
}
|
|
137
|
+
Object.defineProperty(LoaderContainer.prototype, "content", {
|
|
138
|
+
/**
|
|
139
|
+
* Contains the root display object of the SWF file or image(JPG, PNG, or
|
|
140
|
+
* GIF) file that was loaded by using the <code>load()</code> or
|
|
141
|
+
* <code>loadBytes()</code> methods.
|
|
142
|
+
*
|
|
143
|
+
* @throws SecurityError The loaded SWF file or image file belongs to a
|
|
144
|
+
* security sandbox to which you do not have access.
|
|
145
|
+
* For a loaded SWF file, you can avoid this situation
|
|
146
|
+
* by having the file call the
|
|
147
|
+
* <code>Security.allowDomain()</code> method or by
|
|
148
|
+
* having the loading file specify a
|
|
149
|
+
* <code>loaderContext</code> parameter with its
|
|
150
|
+
* <code>securityDomain</code> property set to
|
|
151
|
+
* <code>SecurityDomain.currentDomain</code> when you
|
|
152
|
+
* call the <code>load()</code> or
|
|
153
|
+
* <code>loadBytes()</code> method.
|
|
154
|
+
*/
|
|
155
|
+
get: function () {
|
|
156
|
+
return this._content;
|
|
157
|
+
},
|
|
158
|
+
enumerable: false,
|
|
159
|
+
configurable: true
|
|
160
|
+
});
|
|
161
|
+
Object.defineProperty(LoaderContainer.prototype, "contentLoader", {
|
|
162
|
+
/**
|
|
163
|
+
*
|
|
164
|
+
*/
|
|
165
|
+
get: function () {
|
|
166
|
+
return this._contentLoader;
|
|
167
|
+
},
|
|
168
|
+
enumerable: false,
|
|
169
|
+
configurable: true
|
|
170
|
+
});
|
|
171
|
+
/**
|
|
172
|
+
* Special addEventListener case for <code>
|
|
173
|
+
* URLLoaderEvent.LOAD_ERROR</code> and <code>ype == ParserEvent.PARSE_ERROR</code>
|
|
174
|
+
*
|
|
175
|
+
* @param type
|
|
176
|
+
* @param listener
|
|
177
|
+
*/
|
|
178
|
+
LoaderContainer.prototype.addEventListener = function (type, listener) {
|
|
179
|
+
if (this._contentLoader && type == URLLoaderEvent.LOAD_ERROR || type == ParserEvent.PARSE_ERROR)
|
|
180
|
+
this._contentLoader.addEventListener(type, this._errorDelegateSelector[type]);
|
|
181
|
+
_super.prototype.addEventListener.call(this, type, listener);
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Special removeEventListener case for <code>
|
|
185
|
+
* URLLoaderEvent.LOAD_ERROR</code> and <code>ype == ParserEvent.PARSE_ERROR</code>
|
|
186
|
+
*
|
|
187
|
+
* @param type
|
|
188
|
+
* @param listener
|
|
189
|
+
*/
|
|
190
|
+
LoaderContainer.prototype.removeEventListener = function (type, listener) {
|
|
191
|
+
if (this._contentLoader && type == URLLoaderEvent.LOAD_ERROR || type == ParserEvent.PARSE_ERROR)
|
|
192
|
+
this._contentLoader.removeEventListener(type, this._errorDelegateSelector[type]);
|
|
193
|
+
_super.prototype.removeEventListener.call(this, type, listener);
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Cancels a <code>load()</code> method operation that is currently in
|
|
197
|
+
* progress for the Loader instance.
|
|
198
|
+
*
|
|
199
|
+
*/
|
|
200
|
+
LoaderContainer.prototype.close = function () {
|
|
201
|
+
if (!this._contentLoader)
|
|
202
|
+
return;
|
|
203
|
+
if (this._useAssetLib)
|
|
204
|
+
AssetLibraryBundle.getInstance(this._assetLibId).stopLoader(this._contentLoader);
|
|
205
|
+
this._disposeLoader();
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file into an
|
|
209
|
+
* object that is a child of this Loader object. If you load an animated GIF
|
|
210
|
+
* file, only the first frame is displayed. As the Loader object can contain
|
|
211
|
+
* only a single child, issuing a subsequent <code>load()</code> request
|
|
212
|
+
* terminates the previous request, if still pending, and commences a new
|
|
213
|
+
* load.
|
|
214
|
+
*
|
|
215
|
+
* <p><b>Note</b>: In AIR 1.5 and Flash Player 10, the maximum size for a
|
|
216
|
+
* loaded image is 8,191 pixels in width or height, and the total number of
|
|
217
|
+
* pixels cannot exceed 16,777,215 pixels.(So, if an loaded image is 8,191
|
|
218
|
+
* pixels wide, it can only be 2,048 pixels high.) In Flash Player 9 and
|
|
219
|
+
* earlier and AIR 1.1 and earlier, the limitation is 2,880 pixels in height
|
|
220
|
+
* and 2,880 pixels in width.</p>
|
|
221
|
+
*
|
|
222
|
+
* <p>A SWF file or image loaded into a Loader object inherits the position,
|
|
223
|
+
* rotation, and scale properties of the parent display objects of the Loader
|
|
224
|
+
* object. </p>
|
|
225
|
+
*
|
|
226
|
+
* <p>Use the <code>unload()</code> method to remove movies or images loaded
|
|
227
|
+
* with this method, or to cancel a load operation that is in progress.</p>
|
|
228
|
+
*
|
|
229
|
+
* <p>You can prevent a SWF file from using this method by setting the
|
|
230
|
+
* <code>allowNetworking</code> parameter of the the <code>object</code> and
|
|
231
|
+
* <code>embed</code> tags in the HTML page that contains the SWF
|
|
232
|
+
* content.</p>
|
|
233
|
+
*
|
|
234
|
+
* <p>When you use this method, consider the Flash Player security model,
|
|
235
|
+
* which is described in the Loader class description. </p>
|
|
236
|
+
*
|
|
237
|
+
* <p> In Flash Player 10 and later, if you use a multipart Content-Type(for
|
|
238
|
+
* example "multipart/form-data") that contains an upload(indicated by a
|
|
239
|
+
* "filename" parameter in a "content-disposition" header within the POST
|
|
240
|
+
* body), the POST operation is subject to the security rules applied to
|
|
241
|
+
* uploads:</p>
|
|
242
|
+
*
|
|
243
|
+
* <ul>
|
|
244
|
+
* <li>The POST operation must be performed in response to a user-initiated
|
|
245
|
+
* action, such as a mouse click or key press.</li>
|
|
246
|
+
* <li>If the POST operation is cross-domain(the POST target is not on the
|
|
247
|
+
* same server as the SWF file that is sending the POST request), the target
|
|
248
|
+
* server must provide a URL policy file that permits cross-domain
|
|
249
|
+
* access.</li>
|
|
250
|
+
* </ul>
|
|
251
|
+
*
|
|
252
|
+
* <p>Also, for any multipart Content-Type, the syntax must be valid
|
|
253
|
+
* (according to the RFC2046 standard). If the syntax appears to be invalid,
|
|
254
|
+
* the POST operation is subject to the security rules applied to
|
|
255
|
+
* uploads.</p>
|
|
256
|
+
*
|
|
257
|
+
* <p>For more information related to security, see the Flash Player
|
|
258
|
+
* Developer Center Topic: <a
|
|
259
|
+
* href="http://www.adobe.com/go/devnet_security_en"
|
|
260
|
+
* scope="external">Security</a>.</p>
|
|
261
|
+
*
|
|
262
|
+
* @param request The absolute or relative URL of the SWF, JPEG, GIF, or PNG
|
|
263
|
+
* file to be loaded. A relative path must be relative to the
|
|
264
|
+
* main SWF file. Absolute URLs must include the protocol
|
|
265
|
+
* reference, such as http:// or file:///. Filenames cannot
|
|
266
|
+
* include disk drive specifications.
|
|
267
|
+
* @param context A LoaderContext object, which has properties that define
|
|
268
|
+
* the following:
|
|
269
|
+
* <ul>
|
|
270
|
+
* <li>Whether or not to check for the existence of a policy
|
|
271
|
+
* file upon loading the object</li>
|
|
272
|
+
* <li>The ApplicationDomain for the loaded object</li>
|
|
273
|
+
* <li>The SecurityDomain for the loaded object</li>
|
|
274
|
+
* <li>The ImageDecodingPolicy for the loaded image
|
|
275
|
+
* object</li>
|
|
276
|
+
* </ul>
|
|
277
|
+
*
|
|
278
|
+
* <p>If the <code>context</code> parameter is not specified
|
|
279
|
+
* or refers to a null object, the loaded content remains in
|
|
280
|
+
* its own security domain.</p>
|
|
281
|
+
*
|
|
282
|
+
* <p>For complete details, see the description of the
|
|
283
|
+
* properties in the <a
|
|
284
|
+
* href="../system/LoaderContext.html">LoaderContext</a>
|
|
285
|
+
* class.</p>
|
|
286
|
+
* @param ns An optional namespace string under which the file is to be
|
|
287
|
+
* loaded, allowing the differentiation of two resources with
|
|
288
|
+
* identical assets.
|
|
289
|
+
* @param parser An optional parser object for translating the loaded data
|
|
290
|
+
* into a usable resource. If not provided, Loader will
|
|
291
|
+
* attempt to auto-detect the file type.
|
|
292
|
+
* @throws IOError The <code>digest</code> property of the
|
|
293
|
+
* <code>request</code> object is not
|
|
294
|
+
* <code>null</code>. You should only set the
|
|
295
|
+
* <code>digest</code> property of a URLRequest
|
|
296
|
+
* object when calling the
|
|
297
|
+
* <code>URLLoader.load()</code> method when
|
|
298
|
+
* loading a SWZ file(an Adobe platform
|
|
299
|
+
* component).
|
|
300
|
+
* @throws IllegalOperationError If the <code>requestedContentParent</code>
|
|
301
|
+
* property of the <code>context</code>
|
|
302
|
+
* parameter is a <code>Loader</code>.
|
|
303
|
+
* @throws IllegalOperationError If the <code>LoaderContext.parameters</code>
|
|
304
|
+
* parameter is set to non-null and has some
|
|
305
|
+
* values which are not Strings.
|
|
306
|
+
* @throws SecurityError The value of
|
|
307
|
+
* <code>LoaderContext.securityDomain</code>
|
|
308
|
+
* must be either <code>null</code> or
|
|
309
|
+
* <code>SecurityDomain.currentDomain</code>.
|
|
310
|
+
* This reflects the fact that you can only
|
|
311
|
+
* place the loaded media in its natural
|
|
312
|
+
* security sandbox or your own(the latter
|
|
313
|
+
* requires a policy file).
|
|
314
|
+
* @throws SecurityError Local SWF files may not set
|
|
315
|
+
* LoaderContext.securityDomain to anything
|
|
316
|
+
* other than <code>null</code>. It is not
|
|
317
|
+
* permitted to import non-local media into a
|
|
318
|
+
* local sandbox, or to place other local media
|
|
319
|
+
* in anything other than its natural sandbox.
|
|
320
|
+
* @throws SecurityError You cannot connect to commonly reserved
|
|
321
|
+
* ports. For a complete list of blocked ports,
|
|
322
|
+
* see "Restricting Networking APIs" in the
|
|
323
|
+
* <i>ActionScript 3.0 Developer's Guide</i>.
|
|
324
|
+
* @throws SecurityError If the <code>applicationDomain</code> or
|
|
325
|
+
* <code>securityDomain</code> properties of
|
|
326
|
+
* the <code>context</code> parameter are from
|
|
327
|
+
* a disallowed domain.
|
|
328
|
+
* @throws SecurityError If a local SWF file is attempting to use the
|
|
329
|
+
* <code>securityDomain</code> property of the
|
|
330
|
+
* <code>context</code> parameter.
|
|
331
|
+
* @event asyncError Dispatched by the <code>contentLoaderInfo</code>
|
|
332
|
+
* object if the
|
|
333
|
+
* <code>LoaderContext.requestedContentParent</code>
|
|
334
|
+
* property has been specified and it is not possible to
|
|
335
|
+
* add the loaded content as a child to the specified
|
|
336
|
+
* DisplayObjectContainer. This could happen if the
|
|
337
|
+
* loaded content is a
|
|
338
|
+
* <code>flash.display.AVM1Movie</code> or if the
|
|
339
|
+
* <code>addChild()</code> call to the
|
|
340
|
+
* requestedContentParent throws an error.
|
|
341
|
+
* @event complete Dispatched by the <code>contentLoaderInfo</code>
|
|
342
|
+
* object when the file has completed loading. The
|
|
343
|
+
* <code>complete</code> event is always dispatched
|
|
344
|
+
* after the <code>init</code> event.
|
|
345
|
+
* @event httpStatus Dispatched by the <code>contentLoaderInfo</code>
|
|
346
|
+
* object when a network request is made over HTTP and
|
|
347
|
+
* Flash Player can detect the HTTP status code.
|
|
348
|
+
* @event init Dispatched by the <code>contentLoaderInfo</code>
|
|
349
|
+
* object when the properties and methods of the loaded
|
|
350
|
+
* SWF file are accessible. The <code>init</code> event
|
|
351
|
+
* always precedes the <code>complete</code> event.
|
|
352
|
+
* @event ioError Dispatched by the <code>contentLoaderInfo</code>
|
|
353
|
+
* object when an input or output error occurs that
|
|
354
|
+
* causes a load operation to fail.
|
|
355
|
+
* @event open Dispatched by the <code>contentLoaderInfo</code>
|
|
356
|
+
* object when the loading operation starts.
|
|
357
|
+
* @event progress Dispatched by the <code>contentLoaderInfo</code>
|
|
358
|
+
* object as data is received while load operation
|
|
359
|
+
* progresses.
|
|
360
|
+
* @event securityError Dispatched by the <code>contentLoaderInfo</code>
|
|
361
|
+
* object if a SWF file in the local-with-filesystem
|
|
362
|
+
* sandbox attempts to load content in the
|
|
363
|
+
* local-with-networking sandbox, or vice versa.
|
|
364
|
+
* @event securityError Dispatched by the <code>contentLoaderInfo</code>
|
|
365
|
+
* object if the
|
|
366
|
+
* <code>LoaderContext.requestedContentParent</code>
|
|
367
|
+
* property has been specified and the security sandbox
|
|
368
|
+
* of the
|
|
369
|
+
* <code>LoaderContext.requestedContentParent</code>
|
|
370
|
+
* does not have access to the loaded SWF.
|
|
371
|
+
* @event unload Dispatched by the <code>contentLoaderInfo</code>
|
|
372
|
+
* object when a loaded object is removed.
|
|
373
|
+
*/
|
|
374
|
+
LoaderContainer.prototype.load = function (request, context, ns, parser) {
|
|
375
|
+
if (context === void 0) { context = null; }
|
|
376
|
+
if (ns === void 0) { ns = null; }
|
|
377
|
+
if (parser === void 0) { parser = null; }
|
|
378
|
+
this._getLoader().load(request, context, ns, parser);
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* Loads from binary data stored in a ByteArray object.
|
|
382
|
+
*
|
|
383
|
+
* <p>The <code>loadBytes()</code> method is asynchronous. You must wait for
|
|
384
|
+
* the "init" event before accessing the properties of a loaded object.</p>
|
|
385
|
+
*
|
|
386
|
+
* <p>When you use this method, consider the Flash Player security model,
|
|
387
|
+
* which is described in the Loader class description. </p>
|
|
388
|
+
*
|
|
389
|
+
* @param bytes A ByteArray object. The contents of the ByteArray can be
|
|
390
|
+
* any of the file formats supported by the Loader class: SWF,
|
|
391
|
+
* GIF, JPEG, or PNG.
|
|
392
|
+
* @param context A LoaderContext object. Only the
|
|
393
|
+
* <code>applicationDomain</code> property of the
|
|
394
|
+
* LoaderContext object applies; the
|
|
395
|
+
* <code>checkPolicyFile</code> and
|
|
396
|
+
* <code>securityDomain</code> properties of the LoaderContext
|
|
397
|
+
* object do not apply.
|
|
398
|
+
*
|
|
399
|
+
* <p>If the <code>context</code> parameter is not specified
|
|
400
|
+
* or refers to a null object, the content is loaded into the
|
|
401
|
+
* current security domain - a process referred to as "import
|
|
402
|
+
* loading" in Flash Player security documentation.
|
|
403
|
+
* Specifically, if the loading SWF file trusts the remote SWF
|
|
404
|
+
* by incorporating the remote SWF into its code, then the
|
|
405
|
+
* loading SWF can import it directly into its own security
|
|
406
|
+
* domain.</p>
|
|
407
|
+
*
|
|
408
|
+
* <p>For more information related to security, see the Flash
|
|
409
|
+
* Player Developer Center Topic: <a
|
|
410
|
+
* href="http://www.adobe.com/go/devnet_security_en"
|
|
411
|
+
* scope="external">Security</a>.</p>
|
|
412
|
+
* @throws ArgumentError If the <code>length</code> property of the
|
|
413
|
+
* ByteArray object is not greater than 0.
|
|
414
|
+
* @throws IllegalOperationError If the <code>checkPolicyFile</code> or
|
|
415
|
+
* <code>securityDomain</code> property of the
|
|
416
|
+
* <code>context</code> parameter are non-null.
|
|
417
|
+
* @throws IllegalOperationError If the <code>requestedContentParent</code>
|
|
418
|
+
* property of the <code>context</code>
|
|
419
|
+
* parameter is a <code>Loader</code>.
|
|
420
|
+
* @throws IllegalOperationError If the <code>LoaderContext.parameters</code>
|
|
421
|
+
* parameter is set to non-null and has some
|
|
422
|
+
* values which are not Strings.
|
|
423
|
+
* @throws SecurityError If the provided
|
|
424
|
+
* <code>applicationDomain</code> property of
|
|
425
|
+
* the <code>context</code> property is from a
|
|
426
|
+
* disallowed domain.
|
|
427
|
+
* @throws SecurityError You cannot connect to commonly reserved
|
|
428
|
+
* ports. For a complete list of blocked ports,
|
|
429
|
+
* see "Restricting Networking APIs" in the
|
|
430
|
+
* <i>ActionScript 3.0 Developer's Guide</i>.
|
|
431
|
+
* @event asyncError Dispatched by the <code>contentLoaderInfo</code>
|
|
432
|
+
* object if the
|
|
433
|
+
* <code>LoaderContext.requestedContentParent</code>
|
|
434
|
+
* property has been specified and it is not possible to
|
|
435
|
+
* add the loaded content as a child to the specified
|
|
436
|
+
* DisplayObjectContainer. This could happen if the
|
|
437
|
+
* loaded content is a
|
|
438
|
+
* <code>flash.display.AVM1Movie</code> or if the
|
|
439
|
+
* <code>addChild()</code> call to the
|
|
440
|
+
* requestedContentParent throws an error.
|
|
441
|
+
* @event complete Dispatched by the <code>contentLoaderInfo</code>
|
|
442
|
+
* object when the operation is complete. The
|
|
443
|
+
* <code>complete</code> event is always dispatched
|
|
444
|
+
* after the <code>init</code> event.
|
|
445
|
+
* @event init Dispatched by the <code>contentLoaderInfo</code>
|
|
446
|
+
* object when the properties and methods of the loaded
|
|
447
|
+
* data are accessible. The <code>init</code> event
|
|
448
|
+
* always precedes the <code>complete</code> event.
|
|
449
|
+
* @event ioError Dispatched by the <code>contentLoaderInfo</code>
|
|
450
|
+
* object when the runtime cannot parse the data in the
|
|
451
|
+
* byte array.
|
|
452
|
+
* @event open Dispatched by the <code>contentLoaderInfo</code>
|
|
453
|
+
* object when the operation starts.
|
|
454
|
+
* @event progress Dispatched by the <code>contentLoaderInfo</code>
|
|
455
|
+
* object as data is transfered in memory.
|
|
456
|
+
* @event securityError Dispatched by the <code>contentLoaderInfo</code>
|
|
457
|
+
* object if the
|
|
458
|
+
* <code>LoaderContext.requestedContentParent</code>
|
|
459
|
+
* property has been specified and the security sandbox
|
|
460
|
+
* of the
|
|
461
|
+
* <code>LoaderContext.requestedContentParent</code>
|
|
462
|
+
* does not have access to the loaded SWF.
|
|
463
|
+
* @event unload Dispatched by the <code>contentLoaderInfo</code>
|
|
464
|
+
* object when a loaded object is removed.
|
|
465
|
+
*/
|
|
466
|
+
LoaderContainer.prototype.loadData = function (data, context, ns, parser) {
|
|
467
|
+
if (context === void 0) { context = null; }
|
|
468
|
+
if (ns === void 0) { ns = null; }
|
|
469
|
+
if (parser === void 0) { parser = null; }
|
|
470
|
+
this._getLoader().loadData(data, '', context, ns, parser);
|
|
471
|
+
};
|
|
472
|
+
LoaderContainer.prototype._getLoader = function () {
|
|
473
|
+
if (this._contentLoader)
|
|
474
|
+
this.close();
|
|
475
|
+
this._contentLoader =
|
|
476
|
+
(this._useAssetLib) ? AssetLibraryBundle.getInstance(this._assetLibId).getLoader() : new Loader();
|
|
477
|
+
this._contentLoader.addEventListener(LoaderEvent.LOADER_START, this._onLoaderStartDelegate);
|
|
478
|
+
this._contentLoader.addEventListener(URLLoaderEvent.LOAD_PROGRESS, this._onLoadProgressDelegate);
|
|
479
|
+
this._contentLoader.addEventListener(URLLoaderEvent.LOAD_COMPLETE, this._onLoadCompleteDelegate);
|
|
480
|
+
this._contentLoader.addEventListener(AssetEvent.ASSET_COMPLETE, this._onAssetCompleteDelegate);
|
|
481
|
+
this._contentLoader.addEventListener(LoaderEvent.LOADER_COMPLETE, this._onLoaderCompleteDelegate);
|
|
482
|
+
if (this.hasEventListener(URLLoaderEvent.LOAD_ERROR))
|
|
483
|
+
this._contentLoader.addEventListener(URLLoaderEvent.LOAD_ERROR, this._onLoadErrorDelegate);
|
|
484
|
+
if (this.hasEventListener(ParserEvent.PARSE_ERROR))
|
|
485
|
+
this._contentLoader.addEventListener(ParserEvent.PARSE_ERROR, this._onParseErrorDelegate);
|
|
486
|
+
return this._contentLoader;
|
|
487
|
+
};
|
|
488
|
+
LoaderContainer.prototype._disposeLoader = function () {
|
|
489
|
+
this._contentLoader.removeEventListener(LoaderEvent.LOADER_START, this._onLoaderStartDelegate);
|
|
490
|
+
this._contentLoader.removeEventListener(URLLoaderEvent.LOAD_PROGRESS, this._onLoadProgressDelegate);
|
|
491
|
+
this._contentLoader.removeEventListener(URLLoaderEvent.LOAD_COMPLETE, this._onLoadCompleteDelegate);
|
|
492
|
+
this._contentLoader.removeEventListener(AssetEvent.ASSET_COMPLETE, this._onAssetCompleteDelegate);
|
|
493
|
+
this._contentLoader.removeEventListener(LoaderEvent.LOADER_COMPLETE, this._onLoaderCompleteDelegate);
|
|
494
|
+
if (this.hasEventListener(URLLoaderEvent.LOAD_ERROR))
|
|
495
|
+
this._contentLoader.removeEventListener(URLLoaderEvent.LOAD_ERROR, this._onLoadErrorDelegate);
|
|
496
|
+
if (this.hasEventListener(ParserEvent.PARSE_ERROR))
|
|
497
|
+
this._contentLoader.removeEventListener(ParserEvent.PARSE_ERROR, this._onParseErrorDelegate);
|
|
498
|
+
if (!this._useAssetLib)
|
|
499
|
+
this._contentLoader.stop();
|
|
500
|
+
this._contentLoader = null;
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* Removes a child of this Loader object that was loaded by using the
|
|
504
|
+
* <code>load()</code> method. The <code>property</code> of the associated
|
|
505
|
+
* LoaderInfo object is reset to <code>null</code>. The child is not
|
|
506
|
+
* necessarily destroyed because other objects might have references to it;
|
|
507
|
+
* however, it is no longer a child of the Loader object.
|
|
508
|
+
*
|
|
509
|
+
* <p>As a best practice, before you unload a child SWF file, you should
|
|
510
|
+
* explicitly close any streams in the child SWF file's objects, such as
|
|
511
|
+
* LocalConnection, NetConnection, NetStream, and Sound objects. Otherwise,
|
|
512
|
+
* audio in the child SWF file might continue to play, even though the child
|
|
513
|
+
* SWF file was unloaded. To close streams in the child SWF file, add an
|
|
514
|
+
* event listener to the child that listens for the <code>unload</code>
|
|
515
|
+
* event. When the parent calls <code>Loader.unload()</code>, the
|
|
516
|
+
* <code>unload</code> event is dispatched to the child. The following code
|
|
517
|
+
* shows how you might do this:</p>
|
|
518
|
+
* <pre xml:space="preserve"> public closeAllStreams(evt:Event) {
|
|
519
|
+
* myNetStream.close(); mySound.close(); myNetConnection.close();
|
|
520
|
+
* myLocalConnection.close(); }
|
|
521
|
+
* myMovieClip.loaderInfo.addEventListener(Event.UNLOAD,
|
|
522
|
+
* closeAllStreams);</pre>
|
|
523
|
+
*
|
|
524
|
+
*/
|
|
525
|
+
LoaderContainer.prototype.unload = function () {
|
|
526
|
+
//TODO
|
|
527
|
+
};
|
|
528
|
+
/**
|
|
529
|
+
* Enables a specific parser.
|
|
530
|
+
* When no specific parser is set for a loading/parsing opperation,
|
|
531
|
+
* loader3d can autoselect the correct parser to use.
|
|
532
|
+
* A parser must have been enabled, to be considered when autoselecting the parser.
|
|
533
|
+
*
|
|
534
|
+
* @param parserClass The parser class to enable.
|
|
535
|
+
* @see away.parsers.Parsers
|
|
536
|
+
*/
|
|
537
|
+
LoaderContainer.enableParser = function (parserClass) {
|
|
538
|
+
Loader.enableParser(parserClass);
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
541
|
+
* Enables a list of parsers.
|
|
542
|
+
* When no specific parser is set for a loading/parsing opperation,
|
|
543
|
+
* loader3d can autoselect the correct parser to use.
|
|
544
|
+
* A parser must have been enabled, to be considered when autoselecting the parser.
|
|
545
|
+
*
|
|
546
|
+
* @param parserClasses A Vector of parser classes to enable.
|
|
547
|
+
* @see away.parsers.Parsers
|
|
548
|
+
*/
|
|
549
|
+
LoaderContainer.enableParsers = function (parserClasses) {
|
|
550
|
+
Loader.enableParsers(parserClasses);
|
|
551
|
+
};
|
|
552
|
+
/**
|
|
553
|
+
* .
|
|
554
|
+
*/
|
|
555
|
+
LoaderContainer.prototype._onLoaderStart = function (event) {
|
|
556
|
+
this.dispatchEvent(event);
|
|
557
|
+
};
|
|
558
|
+
LoaderContainer.prototype._onLoadProgress = function (event) {
|
|
559
|
+
this.dispatchEvent(event);
|
|
560
|
+
};
|
|
561
|
+
LoaderContainer.prototype._onLoadComplete = function (event) {
|
|
562
|
+
this.dispatchEvent(event);
|
|
563
|
+
};
|
|
564
|
+
LoaderContainer.prototype._onAssetComplete = function (event) {
|
|
565
|
+
this.dispatchEvent(event);
|
|
566
|
+
};
|
|
567
|
+
/**
|
|
568
|
+
* Called when an error occurs during loading
|
|
569
|
+
*/
|
|
570
|
+
LoaderContainer.prototype._onLoadError = function (event) {
|
|
571
|
+
if (this.hasEventListener(URLLoaderEvent.LOAD_ERROR)) {
|
|
572
|
+
this.dispatchEvent(event);
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
/**
|
|
580
|
+
* Called when a an error occurs during parsing
|
|
581
|
+
*/
|
|
582
|
+
LoaderContainer.prototype._onParseError = function (event) {
|
|
583
|
+
if (this.hasEventListener(ParserEvent.PARSE_ERROR)) {
|
|
584
|
+
this.dispatchEvent(event);
|
|
585
|
+
return true;
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
return false;
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
/**
|
|
592
|
+
* Called when the resource and all of its dependencies was retrieved.
|
|
593
|
+
*/
|
|
594
|
+
LoaderContainer.prototype._onLoaderComplete = function (event) {
|
|
595
|
+
this._content = event.content;
|
|
596
|
+
if (this._content)
|
|
597
|
+
this.addChild(this._content);
|
|
598
|
+
this.dispatchEvent(event);
|
|
599
|
+
this._disposeLoader();
|
|
600
|
+
};
|
|
601
|
+
return LoaderContainer;
|
|
602
|
+
}(DisplayObjectContainer));
|
|
603
|
+
export { LoaderContainer };
|