@awayjs/scene 0.13.325 → 0.13.327
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 -76
- package/dist/index.js +67 -67
- package/dist/lib/Scene.d.ts +85 -85
- package/dist/lib/Scene.d.ts.map +1 -1
- package/dist/lib/Scene.js +285 -285
- package/dist/lib/Settings.d.ts +15 -16
- package/dist/lib/Settings.d.ts.map +1 -1
- package/dist/lib/Settings.js +56 -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 +15 -15
- 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 -26
- package/dist/lib/base/MouseButtons.js +1 -1
- package/dist/lib/base/Timeline.d.ts +147 -147
- package/dist/lib/base/Timeline.js +525 -525
- 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 +132 -132
- package/dist/lib/display/Billboard.js +397 -397
- package/dist/lib/display/Camera.d.ts +31 -31
- package/dist/lib/display/Camera.js +72 -72
- package/dist/lib/display/DisplayObject.d.ts +926 -921
- package/dist/lib/display/DisplayObject.d.ts.map +1 -1
- package/dist/lib/display/DisplayObject.js +1603 -1595
- package/dist/lib/display/DisplayObjectContainer.d.ts +325 -325
- package/dist/lib/display/DisplayObjectContainer.js +486 -486
- package/dist/lib/display/LineSegment.d.ts +69 -69
- package/dist/lib/display/LineSegment.js +203 -203
- 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 +246 -246
- package/dist/lib/display/MovieClip.d.ts +149 -149
- package/dist/lib/display/MovieClip.js +733 -733
- package/dist/lib/display/SimpleButton.d.ts +158 -158
- package/dist/lib/display/SimpleButton.js +228 -228
- package/dist/lib/display/Skybox.d.ts +144 -144
- package/dist/lib/display/Skybox.js +288 -288
- package/dist/lib/display/Sprite.d.ts +65 -65
- package/dist/lib/display/Sprite.js +134 -134
- package/dist/lib/display/TextField.d.ts +1104 -1104
- package/dist/lib/display/TextField.js +3019 -3019
- package/dist/lib/display/TextSprite.d.ts +16 -16
- package/dist/lib/display/TextSprite.js +36 -36
- 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 -91
- package/dist/lib/events/MouseEvent.js +122 -122
- package/dist/lib/events/PointerEvent.d.ts +93 -93
- package/dist/lib/events/PointerEvent.js +73 -73
- 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 +54 -54
- package/dist/lib/events/TouchEvent.js +89 -89
- package/dist/lib/factories/DefaultSceneGraphFactory.d.ts +27 -27
- package/dist/lib/factories/DefaultSceneGraphFactory.js +55 -55
- package/dist/lib/factories/ISceneGraphFactory.d.ts +20 -20
- package/dist/lib/factories/ISceneGraphFactory.js +1 -1
- package/dist/lib/image/SceneImage2D.d.ts +221 -220
- package/dist/lib/image/SceneImage2D.d.ts.map +1 -1
- package/dist/lib/image/SceneImage2D.js +609 -610
- 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 +37 -37
- package/dist/lib/managers/FrameScriptManager.js +386 -386
- package/dist/lib/managers/IInputRecorder.d.ts +3 -3
- package/dist/lib/managers/IInputRecorder.js +1 -1
- package/dist/lib/managers/MouseManager.d.ts +74 -74
- package/dist/lib/managers/MouseManager.js +803 -803
- 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 +73 -73
- package/dist/lib/text/BitmapFontTable.js +183 -183
- 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 +211 -211
- 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 +426 -426
- 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 +88 -88
- package/dist/lib/text/TesselatedFontTable.js +963 -963
- 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 +449 -449
- 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 +22 -22
- 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 -92
- package/lib/Scene.ts +340 -339
- package/lib/Settings.ts +77 -83
- package/lib/adapters/IDisplayObjectAdapter.ts +23 -23
- package/lib/adapters/IFilter.ts +25 -25
- package/lib/adapters/IMovieClipAdapter.ts +26 -26
- 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 -31
- package/lib/base/Timeline.ts +715 -715
- 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 +468 -468
- package/lib/display/Camera.ts +75 -75
- package/lib/display/DisplayObject.ts +1843 -1829
- package/lib/display/DisplayObjectContainer.ts +546 -546
- package/lib/display/LineSegment.ts +229 -229
- package/lib/display/LoaderContainer.ts +651 -651
- package/lib/display/MorphSprite.ts +339 -339
- package/lib/display/MovieClip.ts +870 -870
- package/lib/display/SimpleButton.ts +224 -224
- package/lib/display/Skybox.ts +352 -352
- package/lib/display/Sprite.ts +154 -154
- package/lib/display/TextField.ts +3876 -3876
- package/lib/display/TextSprite.ts +34 -34
- 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 +144 -144
- package/lib/events/PointerEvent.ts +145 -145
- package/lib/events/ResizeEvent.ts +31 -31
- package/lib/events/TextfieldEvent.ts +28 -28
- package/lib/events/TouchEvent.ts +103 -103
- package/lib/factories/DefaultSceneGraphFactory.ts +58 -58
- package/lib/factories/ISceneGraphFactory.ts +28 -28
- package/lib/image/SceneImage2D.ts +912 -912
- package/lib/managers/DefaultFontManager.ts +124 -124
- package/lib/managers/DeviceFontManager.ts +55 -55
- package/lib/managers/FrameScriptManager.ts +440 -440
- package/lib/managers/IInputRecorder.ts +2 -2
- package/lib/managers/MouseManager.ts +942 -942
- 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 +213 -213
- package/lib/text/FNTGenerator.ts +100 -100
- package/lib/text/FNTGeneratorCanvas.ts +292 -292
- 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 +421 -421
- package/lib/text/IFontTable.ts +17 -17
- package/lib/text/TesselatedFontChar.ts +80 -80
- package/lib/text/TesselatedFontTable.ts +1181 -1181
- package/lib/text/TextFieldAutoSize.ts +30 -30
- package/lib/text/TextFieldType.ts +21 -21
- package/lib/text/TextFormat.ts +603 -603
- 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 +91 -91
- 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
package/lib/base/Timeline.ts
CHANGED
|
@@ -1,716 +1,716 @@
|
|
|
1
|
-
import { WaveAudio, ColorTransform, IAsset, Matrix3D } from '@awayjs/core';
|
|
2
|
-
import { BlendMode } from '@awayjs/stage';
|
|
3
|
-
import { HierarchicalProperty } from '@awayjs/view';
|
|
4
|
-
import { Graphics } from '@awayjs/graphics';
|
|
5
|
-
|
|
6
|
-
import { IDisplayObjectAdapter } from '../adapters/IDisplayObjectAdapter';
|
|
7
|
-
import { IFilter } from '../adapters/IFilter';
|
|
8
|
-
import { IMovieClipAdapter } from '../adapters/IMovieClipAdapter';
|
|
9
|
-
import { MovieClip } from '../display/MovieClip';
|
|
10
|
-
import { Sprite } from '../display/Sprite';
|
|
11
|
-
import { MorphSprite } from '../display/MorphSprite';
|
|
12
|
-
import { DisplayObject } from '../display/DisplayObject';
|
|
13
|
-
import { DisplayObjectContainer } from '../display/DisplayObjectContainer';
|
|
14
|
-
import { ISceneGraphFactory } from '../factories/ISceneGraphFactory';
|
|
15
|
-
import { IFrameLabel } from './IFrameLabel';
|
|
16
|
-
import { TimelineActionType as AType } from './TimelineActionType';
|
|
17
|
-
import { IFrameScript } from './IFrameScript';
|
|
18
|
-
|
|
19
|
-
const BLEND_MODES = [
|
|
20
|
-
'', BlendMode.NORMAL, BlendMode.LAYER,
|
|
21
|
-
BlendMode.MULTIPLY, BlendMode.SCREEN,
|
|
22
|
-
BlendMode.LIGHTEN, BlendMode.DARKEN,
|
|
23
|
-
BlendMode.DIFFERENCE, BlendMode.ADD,
|
|
24
|
-
BlendMode.SUBTRACT, BlendMode.INVERT,
|
|
25
|
-
BlendMode.ALPHA, BlendMode.ERASE, BlendMode.OVERLAY,
|
|
26
|
-
BlendMode.HARDLIGHT
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
function mapBlendIdToString(id: number = 1): string {
|
|
30
|
-
return BLEND_MODES[id] || BLEND_MODES[1];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type TApplyFunction = (timeline: Timeline, child: DisplayObject, ratget: MovieClip, i: number) => void;
|
|
34
|
-
export class Timeline {
|
|
35
|
-
public static readonly applyFunctionMap: Record<AType, TApplyFunction > = {
|
|
36
|
-
[AType.UPDATE_MTX]: Timeline.update_mtx_all,
|
|
37
|
-
[AType.UPDATE_CMTX]: Timeline.update_colortransform,
|
|
38
|
-
[AType.UPDATE_MASKS]: Timeline.update_masks,
|
|
39
|
-
[AType.UPDATE_NAME]: Timeline.update_name,
|
|
40
|
-
[AType.UPDATE_BUTTON_NAME]: Timeline.update_button_name,
|
|
41
|
-
[AType.UPDATE_VISIBLE]: Timeline.update_visibility,
|
|
42
|
-
[AType.UPDATE_BLENDMODE]: Timeline.update_blendmode,
|
|
43
|
-
[AType.UPDATE_RENDERMODE]: Timeline.update_rendermode,
|
|
44
|
-
[AType.UPDATE_FILTERS]: Timeline.update_filters,
|
|
45
|
-
[AType.UPDATE_SCALE_ROT]: Timeline.update_mtx_scale_rot,
|
|
46
|
-
[AType.UPDATE_POS]: Timeline.update_mtx_pos,
|
|
47
|
-
[AType.ENABLE_MASKMODE]: Timeline.enable_maskmode,
|
|
48
|
-
[AType.REMOVE_MASK]: Timeline.remove_masks,
|
|
49
|
-
[AType.SWAP_GRAPHICS]: Timeline.swap_graphics,
|
|
50
|
-
[AType.SET_RATIO]: Timeline.set_ratio,
|
|
51
|
-
[AType.START_AUDIO]: Timeline.start_audio
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
private _blocked: boolean;
|
|
55
|
-
|
|
56
|
-
public _update_indices: number[] = [];
|
|
57
|
-
public _update_frames: number[] = [];
|
|
58
|
-
public isButton: boolean = false;
|
|
59
|
-
public _labels: StringMap<IFrameLabel>; // dictionary to store label => keyframeindex
|
|
60
|
-
|
|
61
|
-
public avm1InitActions: Object; // dictionary to store keyframeindex => ExecuteScriptCommand
|
|
62
|
-
public avm1ButtonActions: any[]; // dictionary to store keyframeindex => ExecuteScriptCommand
|
|
63
|
-
public avm1Exports: Object; // dictionary to store keyframeindex => ExecuteScriptCommand
|
|
64
|
-
|
|
65
|
-
// framescripts are not stored by keyframe-index, but by frameIdx
|
|
66
|
-
// this makes it easy to get/set framescripts on the fly, even when no keyframe exists for that frame
|
|
67
|
-
private _framescripts: StringMap<IFrameScript[]>;
|
|
68
|
-
private _framescripts_translated: Object;
|
|
69
|
-
|
|
70
|
-
public keyframe_to_frameidx: Object;
|
|
71
|
-
public keyframe_indices: number[]; //stores 1 keyframeindex per frameindex
|
|
72
|
-
public keyframe_firstframes: number[]; //stores the firstframe of each keyframe
|
|
73
|
-
public keyframe_constructframes: number[]; //stores the previous fullConstruct keyframeindex
|
|
74
|
-
|
|
75
|
-
public keyframe_durations: ArrayBufferView; //only needed to calulcate other arrays
|
|
76
|
-
|
|
77
|
-
// synched:
|
|
78
|
-
public frame_command_indices: ArrayBufferView;
|
|
79
|
-
public frame_recipe: ArrayBufferView;
|
|
80
|
-
|
|
81
|
-
// synched:
|
|
82
|
-
public command_index_stream: ArrayBufferView;
|
|
83
|
-
public command_length_stream: ArrayBufferView;
|
|
84
|
-
|
|
85
|
-
public add_child_stream: ArrayBufferView;
|
|
86
|
-
public add_sounds_stream: ArrayBufferView;
|
|
87
|
-
public remove_child_stream: ArrayBufferView;
|
|
88
|
-
public update_child_stream: ArrayBufferView;
|
|
89
|
-
|
|
90
|
-
public update_child_props_length_stream: ArrayBufferView;
|
|
91
|
-
public update_child_props_indices_stream: ArrayBufferView;
|
|
92
|
-
|
|
93
|
-
public property_index_stream: ArrayBufferView;
|
|
94
|
-
public property_type_stream: ArrayBufferView;
|
|
95
|
-
|
|
96
|
-
public properties_stream_int: ArrayBufferView;
|
|
97
|
-
|
|
98
|
-
// property_values_stream:
|
|
99
|
-
public properties_stream_f32_mtx_all: ArrayBufferView; // list of floats
|
|
100
|
-
public properties_stream_f32_mtx_scale_rot: ArrayBufferView; // list of floats
|
|
101
|
-
public properties_stream_f32_mtx_pos: ArrayBufferView; // list of floats
|
|
102
|
-
public properties_stream_f32_ct: ArrayBufferView; // list of floats
|
|
103
|
-
public properties_stream_strings: string[];
|
|
104
|
-
|
|
105
|
-
public properties_stream_filters: IFilter[];
|
|
106
|
-
|
|
107
|
-
public placeObjectTagsForSessionIDs: NumberMap<any>;
|
|
108
|
-
public graphicsPool: any;
|
|
109
|
-
|
|
110
|
-
public audioPool: any;
|
|
111
|
-
|
|
112
|
-
public numKeyFrames: number;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* in AS3 framescript are getting added to mc by calling "mc.addFrameScript" from within the mc.constructor
|
|
116
|
-
* because timelines are shared between all instances of a mc,
|
|
117
|
-
* only the first instance of a mc should be allowd to add framescripts to the timeline
|
|
118
|
-
* to check this, we track the id of mc-instance that adds the first framescript,
|
|
119
|
-
* and only allow additional framescripts to be added from same instance
|
|
120
|
-
**/
|
|
121
|
-
private _initalMcID: number;
|
|
122
|
-
|
|
123
|
-
constructor(readonly factory: ISceneGraphFactory) {
|
|
124
|
-
|
|
125
|
-
this._initalMcID = -1;
|
|
126
|
-
this.numKeyFrames = 0;
|
|
127
|
-
this.keyframe_indices = [];
|
|
128
|
-
this.avm1Exports = {};
|
|
129
|
-
this.avm1InitActions = {};
|
|
130
|
-
this.avm1ButtonActions = [];
|
|
131
|
-
this.graphicsPool = {};
|
|
132
|
-
this.audioPool = {};
|
|
133
|
-
this.placeObjectTagsForSessionIDs = {};
|
|
134
|
-
this._labels = {};
|
|
135
|
-
this._framescripts = {};
|
|
136
|
-
this._framescripts_translated = {};
|
|
137
|
-
this.keyframe_to_frameidx = {};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
public resetScripts() {
|
|
141
|
-
this._framescripts = {};
|
|
142
|
-
this._framescripts_translated = {};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/* should be called after timeline-streams have been set.
|
|
146
|
-
prepares
|
|
147
|
-
*/
|
|
148
|
-
public init(): void {
|
|
149
|
-
|
|
150
|
-
if ((this.frame_command_indices == null) || (this.frame_recipe == null) || (this.keyframe_durations == null)) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
let frame_cnt = 0;
|
|
155
|
-
let ic = 0;
|
|
156
|
-
let ic2 = 0;
|
|
157
|
-
let duration = 0;
|
|
158
|
-
let keyframe_cnt = 0;
|
|
159
|
-
let last_construct_frame = 0;
|
|
160
|
-
this.keyframe_firstframes = [];
|
|
161
|
-
this.keyframe_constructframes = [];
|
|
162
|
-
this.keyframe_indices = [];
|
|
163
|
-
this.keyframe_to_frameidx = {};
|
|
164
|
-
this.keyframe_to_frameidx[0] = 0;
|
|
165
|
-
let duration_all = 0;
|
|
166
|
-
for (ic = 0; ic < this.numKeyFrames; ic++) {
|
|
167
|
-
|
|
168
|
-
this.keyframe_to_frameidx[ic] = duration_all;
|
|
169
|
-
duration = this.keyframe_durations[(ic)];
|
|
170
|
-
duration_all += duration;
|
|
171
|
-
if (this.frame_recipe[ic] & 1)
|
|
172
|
-
last_construct_frame = keyframe_cnt;
|
|
173
|
-
|
|
174
|
-
this.keyframe_firstframes[keyframe_cnt] = frame_cnt;
|
|
175
|
-
this.keyframe_constructframes[keyframe_cnt++] = last_construct_frame;
|
|
176
|
-
|
|
177
|
-
for (ic2 = 0; ic2 < duration; ic2++)
|
|
178
|
-
this.keyframe_indices[frame_cnt++] = ic;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* for AS3:
|
|
184
|
-
* - called from constructor of MC
|
|
185
|
-
* for AS2:
|
|
186
|
-
* - called when decoding swf-tags to timeline-streams
|
|
187
|
-
* @param script -
|
|
188
|
-
* @param frame_idx - the index of the frame (not the keyframe-index)
|
|
189
|
-
* @param target_mc - the mc-instance that is calling this function
|
|
190
|
-
*/
|
|
191
|
-
public add_framescript(script: any, frame_idx: number, target_mc: MovieClip, isAVM1: boolean = false): void {
|
|
192
|
-
if (this._initalMcID >= 0 && target_mc.id != this._initalMcID)
|
|
193
|
-
return;
|
|
194
|
-
this._initalMcID = target_mc.id;
|
|
195
|
-
if (!this._framescripts[frame_idx]) {
|
|
196
|
-
this._framescripts[frame_idx] = [];
|
|
197
|
-
}
|
|
198
|
-
if (Array.isArray(script)) {
|
|
199
|
-
for (let i = 0; i < script.length; i++) {
|
|
200
|
-
this._framescripts[frame_idx][this._framescripts[frame_idx].length] = script[i];
|
|
201
|
-
}
|
|
202
|
-
} else {
|
|
203
|
-
this._framescripts[frame_idx].push(script);
|
|
204
|
-
}
|
|
205
|
-
this._framescripts_translated[frame_idx] = !isAVM1;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* get a array of framescripts for a specific frame
|
|
210
|
-
* for AVM1 "checkForTranslation" should be true, so we get translated framescripts
|
|
211
|
-
* @param target_mc
|
|
212
|
-
* @param frame_idx
|
|
213
|
-
* @param checkForTranslation
|
|
214
|
-
*/
|
|
215
|
-
public get_script_for_frame(
|
|
216
|
-
target_mc: MovieClip,
|
|
217
|
-
frame_idx: number,
|
|
218
|
-
checkForTranslation: boolean = false): IFrameScript[] {
|
|
219
|
-
|
|
220
|
-
if (frame_idx >= 0 && this._framescripts[frame_idx]) {
|
|
221
|
-
if (checkForTranslation && !this._framescripts_translated[frame_idx]) {
|
|
222
|
-
// todo: cleanup so we can retrieve className of target_mc without hacks
|
|
223
|
-
const name = (<any>target_mc).className ? (<any>target_mc).className : target_mc.name;
|
|
224
|
-
this._framescripts[frame_idx] = this.factory.createFrameScripts(
|
|
225
|
-
this._framescripts[frame_idx],
|
|
226
|
-
frame_idx,
|
|
227
|
-
name,
|
|
228
|
-
target_mc.id);
|
|
229
|
-
this._framescripts_translated[frame_idx] = true;
|
|
230
|
-
}
|
|
231
|
-
return this._framescripts[frame_idx];
|
|
232
|
-
}
|
|
233
|
-
return null;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
public get numFrames(): number {
|
|
237
|
-
return this.keyframe_indices.length;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
public getKeyframeIndexForFrameIndex(frame_index: number): number {
|
|
241
|
-
return this.keyframe_indices[frame_index];
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
public getChildInstance(symbolID: number, sessionID: number) {
|
|
245
|
-
return this.factory.createChildInstanceForTimeline(this, symbolID, sessionID);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
public extractHitArea(target_mc: MovieClip): DisplayObjectContainer {
|
|
249
|
-
target_mc.reset(false);
|
|
250
|
-
this.gotoFrame(target_mc, this.numFrames - 1, false);
|
|
251
|
-
let i: number = target_mc.numChildren;
|
|
252
|
-
const hitArea: DisplayObjectContainer = new DisplayObjectContainer();
|
|
253
|
-
let child: DisplayObject;
|
|
254
|
-
let originalChild: DisplayObject;
|
|
255
|
-
while (i > 0) {
|
|
256
|
-
i--;
|
|
257
|
-
originalChild = target_mc.getChildAt(i);
|
|
258
|
-
child = originalChild.clone();
|
|
259
|
-
//child.reset();
|
|
260
|
-
|
|
261
|
-
child.x = originalChild.x;
|
|
262
|
-
child.scaleX = originalChild.scaleX;
|
|
263
|
-
child.y = originalChild.y;
|
|
264
|
-
child.scaleY = originalChild.scaleY;
|
|
265
|
-
child.rotationZ = originalChild.rotationZ;
|
|
266
|
-
hitArea.addChild(child);
|
|
267
|
-
}
|
|
268
|
-
hitArea.pickObjectFromTimeline = true;
|
|
269
|
-
target_mc.pickObject = hitArea;
|
|
270
|
-
target_mc.reset(false);
|
|
271
|
-
return hitArea;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Get the label at the current frame of the target_mc MovieClip instance.
|
|
276
|
-
* If the current frame has no label, it returns null
|
|
277
|
-
* @param target_mc
|
|
278
|
-
*/
|
|
279
|
-
public getCurrentFrameLabel(target_mc: MovieClip): string {
|
|
280
|
-
const firstFrameIdxOfCurKeyFrame = this.keyframe_to_frameidx[target_mc.constructedKeyFrameIndex];
|
|
281
|
-
for (const key in this._labels) {
|
|
282
|
-
if (this._labels[key].keyFrameIndex == target_mc.constructedKeyFrameIndex &&
|
|
283
|
-
firstFrameIdxOfCurKeyFrame == target_mc.currentFrameIndex) {
|
|
284
|
-
return this._labels[key].name;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
return null;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Get the label at the current frame of the target_mc MovieClip instance.
|
|
292
|
-
* If the current frame has no label it returns the name of the previous frame that includes a label.
|
|
293
|
-
* If the current frame and previous frames do not include a label, it returns null
|
|
294
|
-
* @param target_mc
|
|
295
|
-
*/
|
|
296
|
-
public getCurrentLabel(target_mc: MovieClip): string {
|
|
297
|
-
let label: string = null;
|
|
298
|
-
let lastLabelframeIdx: number = -1;
|
|
299
|
-
for (const key in this._labels) {
|
|
300
|
-
const keyIndex = this._labels[key].keyFrameIndex;
|
|
301
|
-
if (keyIndex > lastLabelframeIdx && keyIndex <= target_mc.constructedKeyFrameIndex) {
|
|
302
|
-
lastLabelframeIdx = keyIndex;
|
|
303
|
-
label = this._labels[key].name;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
return label;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
public jumpToLabel(target_mc: MovieClip, label: string, offset: number = 0): void {
|
|
310
|
-
if (!this._labels[label]) {
|
|
311
|
-
console.warn('[TIMELINE] - jumpToLabel with invalid label', target_mc, label, offset);
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
const key_frame_index: number = this._labels[label].keyFrameIndex;
|
|
315
|
-
if (key_frame_index >= 0)
|
|
316
|
-
target_mc.currentFrameIndex = this.keyframe_firstframes[key_frame_index] + offset;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Get scripts for a specific frame
|
|
321
|
-
* atm this is only called from AVM1MovieClip._callFrame
|
|
322
|
-
* @param target_mc
|
|
323
|
-
* @param label
|
|
324
|
-
* @param isAVM1
|
|
325
|
-
*/
|
|
326
|
-
public getScriptForLabel(target_mc: MovieClip, label: string, isAVM1: boolean = false): IFrameScript[] {
|
|
327
|
-
const key_frame_index: number = this._labels[label.toLowerCase()].keyFrameIndex;
|
|
328
|
-
if (key_frame_index < 0)
|
|
329
|
-
return null;
|
|
330
|
-
const frameIdx: number = this.keyframe_firstframes[key_frame_index];
|
|
331
|
-
if (frameIdx >= 0 && this._framescripts[frameIdx]) {
|
|
332
|
-
return this.get_script_for_frame(target_mc, frameIdx, isAVM1);
|
|
333
|
-
}
|
|
334
|
-
return null;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* move the playhead of the timeline to a specific frame
|
|
339
|
-
* @param target_mc
|
|
340
|
-
* @param frame_idx
|
|
341
|
-
* @param queue_script
|
|
342
|
-
* @param queue_pass2
|
|
343
|
-
* @param forceReconstruct
|
|
344
|
-
*/
|
|
345
|
-
public gotoFrame(target_mc: MovieClip, frame_idx: number,
|
|
346
|
-
queue_script: boolean = true,
|
|
347
|
-
queue_pass2: boolean = false,
|
|
348
|
-
forceReconstruct: boolean = false): void {
|
|
349
|
-
const current_keyframe_idx: number = target_mc.constructedKeyFrameIndex;
|
|
350
|
-
const target_keyframe_idx: number = this.keyframe_indices[frame_idx];
|
|
351
|
-
|
|
352
|
-
if (current_keyframe_idx == target_keyframe_idx && !forceReconstruct) {
|
|
353
|
-
(<IMovieClipAdapter>target_mc.adapter).queueFrameScripts(this, frame_idx, queue_script);
|
|
354
|
-
return;
|
|
355
|
-
} else if (current_keyframe_idx + 1 == target_keyframe_idx) {
|
|
356
|
-
// target_keyframe_idx is the next keyframe. we can just use constructnext for this
|
|
357
|
-
this.constructNextFrame(target_mc, queue_script, true);
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// when constructing a frame we must start constructing
|
|
362
|
-
// either at the beginning of the timeline, or at a frame where all object was removed
|
|
363
|
-
// construct_keyframe_idx is the index of the first keyframe we must process
|
|
364
|
-
const construct_keyframe_idx: number = this.keyframe_constructframes[target_keyframe_idx];
|
|
365
|
-
|
|
366
|
-
// 3 keyframes:
|
|
367
|
-
// - current_keyframe_idx
|
|
368
|
-
// - target_keyframe_idx
|
|
369
|
-
// - construct_keyframe_idx
|
|
370
|
-
|
|
371
|
-
// normally construction must start at construct_keyframe_idx
|
|
372
|
-
// if we jump forward, and target_keyframe_idx >
|
|
373
|
-
|
|
374
|
-
let start_construct_idx: number = construct_keyframe_idx;
|
|
375
|
-
|
|
376
|
-
const jump_forward: boolean = (target_keyframe_idx > current_keyframe_idx);
|
|
377
|
-
if (jump_forward && current_keyframe_idx > construct_keyframe_idx)
|
|
378
|
-
start_construct_idx = current_keyframe_idx + 1;
|
|
379
|
-
|
|
380
|
-
(<IMovieClipAdapter>target_mc.adapter).constructFrame(this, start_construct_idx,
|
|
381
|
-
target_keyframe_idx,
|
|
382
|
-
jump_forward,
|
|
383
|
-
frame_idx,
|
|
384
|
-
queue_pass2,
|
|
385
|
-
queue_script);
|
|
386
|
-
|
|
387
|
-
// apply update commands for objects still on stage (only if they are not blocked by script)
|
|
388
|
-
this.applyCollectedUpdateCommands(target_mc);
|
|
389
|
-
|
|
390
|
-
target_mc.constructedKeyFrameIndex = target_keyframe_idx;
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
public applyCollectedUpdateCommands(target_mc: MovieClip): void {
|
|
395
|
-
let k: number;
|
|
396
|
-
const len: number = this._update_indices.length;
|
|
397
|
-
for (k = 0; k < len; k++)
|
|
398
|
-
this.update_childs(target_mc, this._update_indices[k], this._update_frames[k]);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* constructs the next frame of the timeline
|
|
403
|
-
* expects the target_mc.currentFrameIndex to already be set to the next frame
|
|
404
|
-
* @param target_mc
|
|
405
|
-
* @param queueScript
|
|
406
|
-
* @param scriptPass1
|
|
407
|
-
*/
|
|
408
|
-
public constructNextFrame(target_mc: MovieClip, queueScript: boolean = true, scriptPass1: boolean = false): void {
|
|
409
|
-
const frameIndex: number = target_mc.currentFrameIndex;
|
|
410
|
-
const new_keyFrameIndex: number = this.keyframe_indices[frameIndex];
|
|
411
|
-
|
|
412
|
-
if (queueScript)
|
|
413
|
-
(<IMovieClipAdapter>target_mc.adapter).queueFrameScripts(this, frameIndex, scriptPass1);
|
|
414
|
-
|
|
415
|
-
if (target_mc.constructedKeyFrameIndex != new_keyFrameIndex) {
|
|
416
|
-
target_mc.constructedKeyFrameIndex = new_keyFrameIndex;
|
|
417
|
-
|
|
418
|
-
let frame_command_idx = this.frame_command_indices[new_keyFrameIndex];
|
|
419
|
-
const frame_recipe = this.frame_recipe[new_keyFrameIndex];
|
|
420
|
-
|
|
421
|
-
if (frame_recipe & 1) {
|
|
422
|
-
(<IMovieClipAdapter>target_mc.adapter).removeAllTimelineChilds();
|
|
423
|
-
} else if (frame_recipe & 2) {
|
|
424
|
-
this.remove_childs_continous(target_mc, frame_command_idx++);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
if (frame_recipe & 4)
|
|
428
|
-
this.add_childs_continous(target_mc, frame_command_idx++);
|
|
429
|
-
|
|
430
|
-
if (frame_recipe & 8)
|
|
431
|
-
this.update_childs(target_mc, frame_command_idx++);
|
|
432
|
-
|
|
433
|
-
if (frame_recipe & 16)
|
|
434
|
-
this.start_sounds(target_mc, frame_command_idx++);
|
|
435
|
-
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
public remove_childs_continous(sourceMovieClip: MovieClip, frame_command_idx: number): void {
|
|
440
|
-
const start_index: number = this.command_index_stream[frame_command_idx];
|
|
441
|
-
const end_index: number = start_index + this.command_length_stream[frame_command_idx];
|
|
442
|
-
for (let i: number = start_index; i < end_index; i++) {
|
|
443
|
-
// in avm1 we remove by depth, in avm2 we remove by sessionID
|
|
444
|
-
(<IMovieClipAdapter>sourceMovieClip.adapter).removeTimelineChildAt(this.remove_child_stream[i]);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
public add_childs_continous(target_mc: MovieClip, frame_command_idx: number): void {
|
|
449
|
-
let idx: number;
|
|
450
|
-
const start_index: number = this.command_index_stream[frame_command_idx];
|
|
451
|
-
const end_index: number = start_index + this.command_length_stream[frame_command_idx];
|
|
452
|
-
for (let i: number = start_index; i < end_index; i++) {
|
|
453
|
-
idx = i * 3;
|
|
454
|
-
if (typeof this.add_child_stream[idx] === 'undefined') {
|
|
455
|
-
console.warn('[Timeline] - add_childs_continous - could not find child-id in child_stream for idx',
|
|
456
|
-
idx, this.add_child_stream);
|
|
457
|
-
continue;
|
|
458
|
-
}
|
|
459
|
-
const childAsset: IAsset = this.factory.createChildInstanceForTimeline(this,
|
|
460
|
-
this.add_child_stream[idx + 2], this.add_child_stream[idx]);
|
|
461
|
-
(<IMovieClipAdapter>target_mc.adapter).addTimelineChildAtDepth(<DisplayObject>childAsset,
|
|
462
|
-
this.add_child_stream[idx + 1]);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
public start_sounds(target_mc: MovieClip, frame_command_idx: number): void {
|
|
467
|
-
const start_index: number = this.command_index_stream[frame_command_idx];
|
|
468
|
-
const end_index: number = start_index + this.command_length_stream[frame_command_idx];
|
|
469
|
-
for (let i: number = start_index; i < end_index; i++) {
|
|
470
|
-
const audioProps: any = this.audioPool[this.add_sounds_stream[i]];
|
|
471
|
-
if (audioProps) {
|
|
472
|
-
const sound: WaveAudio = audioProps.sound;
|
|
473
|
-
|
|
474
|
-
if (!sound) {
|
|
475
|
-
console.warn('[Timeline] Missing sound in audioProps!', audioProps);
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
if (audioProps.cmd == 15) {// start sound
|
|
480
|
-
target_mc.startSound(sound, audioProps.props.loopCount || 0);
|
|
481
|
-
} else if (audioProps.cmd == 16) {// stop sound
|
|
482
|
-
target_mc.stopSound(sound);
|
|
483
|
-
}
|
|
484
|
-
//console.log("start sound:", child);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
public update_childs(target_mc: MovieClip, frame_command_idx: number, frameIdx: number = -1): void {
|
|
491
|
-
|
|
492
|
-
const start = this.command_index_stream[frame_command_idx];
|
|
493
|
-
const end = start + this.command_length_stream[frame_command_idx];
|
|
494
|
-
|
|
495
|
-
for (let i = start; i < end; i++) {
|
|
496
|
-
const child = target_mc.getTimelineChildAtSessionID(this.update_child_stream[i]);
|
|
497
|
-
|
|
498
|
-
if (!child) {
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
// check if the child is blocked by script for transform
|
|
503
|
-
this._blocked = !!(child._adapter && (<IDisplayObjectAdapter> child.adapter).isBlockedByScript());
|
|
504
|
-
|
|
505
|
-
const propsStart = this.update_child_props_indices_stream[i];
|
|
506
|
-
const propsEnd = propsStart + this.update_child_props_length_stream[i];
|
|
507
|
-
|
|
508
|
-
for (let p = propsStart; p < propsEnd; p++) {
|
|
509
|
-
Timeline.applyFunctionMap[this.property_type_stream[p]] (
|
|
510
|
-
this,
|
|
511
|
-
child,
|
|
512
|
-
target_mc,
|
|
513
|
-
this.property_index_stream[p]
|
|
514
|
-
);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
public static update_mtx_all(timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, i: number): void {
|
|
520
|
-
if (timeline._blocked || (<any>child).noTimelineUpdate)
|
|
521
|
-
return;
|
|
522
|
-
|
|
523
|
-
i *= 6;
|
|
524
|
-
|
|
525
|
-
const new_matrix: Matrix3D = child.transform.matrix3D;
|
|
526
|
-
const props_stream = timeline.properties_stream_f32_mtx_all;
|
|
527
|
-
|
|
528
|
-
new_matrix._rawData[0] = props_stream[i++];
|
|
529
|
-
new_matrix._rawData[1] = props_stream[i++];
|
|
530
|
-
new_matrix._rawData[4] = props_stream[i++];
|
|
531
|
-
new_matrix._rawData[5] = props_stream[i++];
|
|
532
|
-
new_matrix._rawData[12] = props_stream[i++];
|
|
533
|
-
new_matrix._rawData[13] = props_stream[i];
|
|
534
|
-
|
|
535
|
-
child.transform.invalidateComponents();
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
public static update_colortransform(
|
|
539
|
-
timeline: Timeline,child: DisplayObject, _target_mc: MovieClip, i: number
|
|
540
|
-
): void {
|
|
541
|
-
|
|
542
|
-
if (child._adapter && (<IDisplayObjectAdapter> child.adapter).isColorTransformByScript())
|
|
543
|
-
return;
|
|
544
|
-
|
|
545
|
-
i *= 8;
|
|
546
|
-
const props_stream = timeline.properties_stream_f32_ct;
|
|
547
|
-
const new_ct = child.transform.colorTransform || (child.transform.colorTransform = new ColorTransform());
|
|
548
|
-
|
|
549
|
-
new_ct._rawData[0] = props_stream[i++];
|
|
550
|
-
new_ct._rawData[1] = props_stream[i++];
|
|
551
|
-
new_ct._rawData[2] = props_stream[i++];
|
|
552
|
-
new_ct._rawData[3] = props_stream[i++];
|
|
553
|
-
new_ct._rawData[4] = props_stream[i++];
|
|
554
|
-
new_ct._rawData[5] = props_stream[i++];
|
|
555
|
-
new_ct._rawData[6] = props_stream[i++];
|
|
556
|
-
new_ct._rawData[7] = props_stream[i];
|
|
557
|
-
|
|
558
|
-
child.transform.invalidateColorTransform();
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
public static update_masks(timeline: Timeline, child: DisplayObject, target_mc: MovieClip, i: number): void {
|
|
562
|
-
// an object could have a multiple groups of masks, in case a graphic clip was merged into the timeline
|
|
563
|
-
// this is not implemented in the runtime yet
|
|
564
|
-
// for now, a second mask-group would overwrite the first one
|
|
565
|
-
const masks: Array<DisplayObject> = [];
|
|
566
|
-
const numMasks = timeline.properties_stream_int[i++];
|
|
567
|
-
|
|
568
|
-
if (numMasks === 0) {
|
|
569
|
-
child.timelineMasks = undefined;
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
//mask may not exist if a goto command moves the playhead to a point in the timeline after
|
|
574
|
-
//one of the masks in a mask array has already been removed. Therefore a check is needed.
|
|
575
|
-
for (let m = 0; m < numMasks; m++) {
|
|
576
|
-
masks.push(target_mc.getTimelineChildAtSessionID(timeline.properties_stream_int[i + m]));
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
child.timelineMasks = masks;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
public static update_name(timeline: Timeline, child: DisplayObject, target_mc: MovieClip, i: number): void {
|
|
583
|
-
if (timeline.properties_stream_strings[i].indexOf('instance') == 0) {
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
(<IMovieClipAdapter>target_mc.adapter).unregisterScriptObject(child);
|
|
588
|
-
child.name = timeline.properties_stream_strings[i];
|
|
589
|
-
(<IMovieClipAdapter> target_mc.adapter).registerScriptObject(child);
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
public static update_button_name(
|
|
593
|
-
timeline: Timeline, target: DisplayObject, sourceMovieClip: MovieClip, i: number
|
|
594
|
-
): void {
|
|
595
|
-
|
|
596
|
-
target.name = timeline.properties_stream_strings[i];
|
|
597
|
-
(<MovieClip> target).addButtonListeners();
|
|
598
|
-
(<IMovieClipAdapter> sourceMovieClip.adapter).registerScriptObject(target);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
public static update_visibility(_timeline: Timeline, child: DisplayObject, target_mc: MovieClip, i: number): void {
|
|
602
|
-
if (!child._adapter || !(<IDisplayObjectAdapter> child.adapter).isVisibilityByScript()) {
|
|
603
|
-
child.visible = !!i;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
public static update_mtx_scale_rot(
|
|
608
|
-
timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, i: number
|
|
609
|
-
): void {
|
|
610
|
-
|
|
611
|
-
if (timeline._blocked || (<any>child).noTimelineUpdate) {
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
i *= 4;
|
|
616
|
-
|
|
617
|
-
const new_matrix: Matrix3D = child.transform.matrix3D;
|
|
618
|
-
const props_stream = timeline.properties_stream_f32_mtx_scale_rot;
|
|
619
|
-
|
|
620
|
-
new_matrix._rawData[0] = props_stream[i++];
|
|
621
|
-
new_matrix._rawData[1] = props_stream[i++];
|
|
622
|
-
new_matrix._rawData[4] = props_stream[i++];
|
|
623
|
-
new_matrix._rawData[5] = props_stream[i];
|
|
624
|
-
|
|
625
|
-
child.transform.invalidateComponents();
|
|
626
|
-
|
|
627
|
-
child._invalidateHierarchicalProperty(HierarchicalProperty.SCENE_TRANSFORM);
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
public static update_mtx_pos(timeline: Timeline, child: DisplayObject, target_mc: MovieClip, i: number): void {
|
|
631
|
-
if (timeline._blocked || (<any>child).noTimelineUpdate)
|
|
632
|
-
return;
|
|
633
|
-
|
|
634
|
-
i *= 2;
|
|
635
|
-
|
|
636
|
-
const new_matrix = child.transform.matrix3D;
|
|
637
|
-
|
|
638
|
-
new_matrix._rawData[12] = timeline.properties_stream_f32_mtx_pos[i++];
|
|
639
|
-
new_matrix._rawData[13] = timeline.properties_stream_f32_mtx_pos[i];
|
|
640
|
-
|
|
641
|
-
child.transform.invalidatePosition();
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
public static enable_maskmode(_timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, _i: number): void {
|
|
645
|
-
child.maskMode = true;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
public static remove_masks(_timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, _i: number): void {
|
|
649
|
-
child.timelineMasks = undefined;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
public static update_filters(timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, i: number): void {
|
|
653
|
-
const startFilter: number = timeline.properties_stream_int[i++];
|
|
654
|
-
const numFilter: number = timeline.properties_stream_int[i++];
|
|
655
|
-
const adapter = <IDisplayObjectAdapter>child.adapter;
|
|
656
|
-
|
|
657
|
-
if (numFilter === 0) {
|
|
658
|
-
adapter.updateFilters(null);
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
adapter.updateFilters(
|
|
663
|
-
timeline.properties_stream_filters.slice(startFilter, startFilter + numFilter)
|
|
664
|
-
);
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
public static swap_graphics(timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, i: number): void {
|
|
668
|
-
if (!child.isAsset(Sprite)) {
|
|
669
|
-
console.warn('[Timeline] - swap_graphics - child is not a Sprite');
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
const sprite = <Sprite>child;
|
|
674
|
-
const target = <Graphics> timeline.graphicsPool[timeline.properties_stream_int[i]];
|
|
675
|
-
|
|
676
|
-
if (target.id === sprite.graphics.id) {
|
|
677
|
-
// already the same graphics
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
sprite.graphics = target;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
public static start_audio(_timeline: Timeline, _child: DisplayObject, _target_mc: MovieClip, _i: number): void {}
|
|
685
|
-
|
|
686
|
-
public static set_ratio(_timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, i: number): void {
|
|
687
|
-
if (!child.isAsset(MorphSprite)) {
|
|
688
|
-
console.warn('[Timeline] - set_ratio - child is not a MorphSprite');
|
|
689
|
-
return;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
(<MorphSprite>child).setRatio(_timeline.properties_stream_int[i] / 0xffff);
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
public static update_blendmode(_timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, i: number): void {
|
|
696
|
-
child.blendMode = mapBlendIdToString(i);
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
public static update_rendermode(
|
|
700
|
-
_timeline: Timeline, _child: DisplayObject, _target_mc: MovieClip, i: number): void {
|
|
701
|
-
console.log('update rendermode ' + i);
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
public dispose() {
|
|
705
|
-
this.keyframe_indices = [];
|
|
706
|
-
this.avm1Exports = {};
|
|
707
|
-
this.avm1InitActions = {};
|
|
708
|
-
this.avm1ButtonActions = [];
|
|
709
|
-
this.graphicsPool = {};
|
|
710
|
-
this.audioPool = {};
|
|
711
|
-
this.placeObjectTagsForSessionIDs = {};
|
|
712
|
-
this._labels = {};
|
|
713
|
-
this._framescripts = {};
|
|
714
|
-
this._framescripts_translated = {};
|
|
715
|
-
}
|
|
1
|
+
import { WaveAudio, ColorTransform, IAsset, Matrix3D } from '@awayjs/core';
|
|
2
|
+
import { BlendMode } from '@awayjs/stage';
|
|
3
|
+
import { HierarchicalProperty } from '@awayjs/view';
|
|
4
|
+
import { Graphics } from '@awayjs/graphics';
|
|
5
|
+
|
|
6
|
+
import { IDisplayObjectAdapter } from '../adapters/IDisplayObjectAdapter';
|
|
7
|
+
import { IFilter } from '../adapters/IFilter';
|
|
8
|
+
import { IMovieClipAdapter } from '../adapters/IMovieClipAdapter';
|
|
9
|
+
import { MovieClip } from '../display/MovieClip';
|
|
10
|
+
import { Sprite } from '../display/Sprite';
|
|
11
|
+
import { MorphSprite } from '../display/MorphSprite';
|
|
12
|
+
import { DisplayObject } from '../display/DisplayObject';
|
|
13
|
+
import { DisplayObjectContainer } from '../display/DisplayObjectContainer';
|
|
14
|
+
import { ISceneGraphFactory } from '../factories/ISceneGraphFactory';
|
|
15
|
+
import { IFrameLabel } from './IFrameLabel';
|
|
16
|
+
import { TimelineActionType as AType } from './TimelineActionType';
|
|
17
|
+
import { IFrameScript } from './IFrameScript';
|
|
18
|
+
|
|
19
|
+
const BLEND_MODES = [
|
|
20
|
+
'', BlendMode.NORMAL, BlendMode.LAYER,
|
|
21
|
+
BlendMode.MULTIPLY, BlendMode.SCREEN,
|
|
22
|
+
BlendMode.LIGHTEN, BlendMode.DARKEN,
|
|
23
|
+
BlendMode.DIFFERENCE, BlendMode.ADD,
|
|
24
|
+
BlendMode.SUBTRACT, BlendMode.INVERT,
|
|
25
|
+
BlendMode.ALPHA, BlendMode.ERASE, BlendMode.OVERLAY,
|
|
26
|
+
BlendMode.HARDLIGHT
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
function mapBlendIdToString(id: number = 1): string {
|
|
30
|
+
return BLEND_MODES[id] || BLEND_MODES[1];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type TApplyFunction = (timeline: Timeline, child: DisplayObject, ratget: MovieClip, i: number) => void;
|
|
34
|
+
export class Timeline {
|
|
35
|
+
public static readonly applyFunctionMap: Record<AType, TApplyFunction > = {
|
|
36
|
+
[AType.UPDATE_MTX]: Timeline.update_mtx_all,
|
|
37
|
+
[AType.UPDATE_CMTX]: Timeline.update_colortransform,
|
|
38
|
+
[AType.UPDATE_MASKS]: Timeline.update_masks,
|
|
39
|
+
[AType.UPDATE_NAME]: Timeline.update_name,
|
|
40
|
+
[AType.UPDATE_BUTTON_NAME]: Timeline.update_button_name,
|
|
41
|
+
[AType.UPDATE_VISIBLE]: Timeline.update_visibility,
|
|
42
|
+
[AType.UPDATE_BLENDMODE]: Timeline.update_blendmode,
|
|
43
|
+
[AType.UPDATE_RENDERMODE]: Timeline.update_rendermode,
|
|
44
|
+
[AType.UPDATE_FILTERS]: Timeline.update_filters,
|
|
45
|
+
[AType.UPDATE_SCALE_ROT]: Timeline.update_mtx_scale_rot,
|
|
46
|
+
[AType.UPDATE_POS]: Timeline.update_mtx_pos,
|
|
47
|
+
[AType.ENABLE_MASKMODE]: Timeline.enable_maskmode,
|
|
48
|
+
[AType.REMOVE_MASK]: Timeline.remove_masks,
|
|
49
|
+
[AType.SWAP_GRAPHICS]: Timeline.swap_graphics,
|
|
50
|
+
[AType.SET_RATIO]: Timeline.set_ratio,
|
|
51
|
+
[AType.START_AUDIO]: Timeline.start_audio
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
private _blocked: boolean;
|
|
55
|
+
|
|
56
|
+
public _update_indices: number[] = [];
|
|
57
|
+
public _update_frames: number[] = [];
|
|
58
|
+
public isButton: boolean = false;
|
|
59
|
+
public _labels: StringMap<IFrameLabel>; // dictionary to store label => keyframeindex
|
|
60
|
+
|
|
61
|
+
public avm1InitActions: Object; // dictionary to store keyframeindex => ExecuteScriptCommand
|
|
62
|
+
public avm1ButtonActions: any[]; // dictionary to store keyframeindex => ExecuteScriptCommand
|
|
63
|
+
public avm1Exports: Object; // dictionary to store keyframeindex => ExecuteScriptCommand
|
|
64
|
+
|
|
65
|
+
// framescripts are not stored by keyframe-index, but by frameIdx
|
|
66
|
+
// this makes it easy to get/set framescripts on the fly, even when no keyframe exists for that frame
|
|
67
|
+
private _framescripts: StringMap<IFrameScript[]>;
|
|
68
|
+
private _framescripts_translated: Object;
|
|
69
|
+
|
|
70
|
+
public keyframe_to_frameidx: Object;
|
|
71
|
+
public keyframe_indices: number[]; //stores 1 keyframeindex per frameindex
|
|
72
|
+
public keyframe_firstframes: number[]; //stores the firstframe of each keyframe
|
|
73
|
+
public keyframe_constructframes: number[]; //stores the previous fullConstruct keyframeindex
|
|
74
|
+
|
|
75
|
+
public keyframe_durations: ArrayBufferView; //only needed to calulcate other arrays
|
|
76
|
+
|
|
77
|
+
// synched:
|
|
78
|
+
public frame_command_indices: ArrayBufferView;
|
|
79
|
+
public frame_recipe: ArrayBufferView;
|
|
80
|
+
|
|
81
|
+
// synched:
|
|
82
|
+
public command_index_stream: ArrayBufferView;
|
|
83
|
+
public command_length_stream: ArrayBufferView;
|
|
84
|
+
|
|
85
|
+
public add_child_stream: ArrayBufferView;
|
|
86
|
+
public add_sounds_stream: ArrayBufferView;
|
|
87
|
+
public remove_child_stream: ArrayBufferView;
|
|
88
|
+
public update_child_stream: ArrayBufferView;
|
|
89
|
+
|
|
90
|
+
public update_child_props_length_stream: ArrayBufferView;
|
|
91
|
+
public update_child_props_indices_stream: ArrayBufferView;
|
|
92
|
+
|
|
93
|
+
public property_index_stream: ArrayBufferView;
|
|
94
|
+
public property_type_stream: ArrayBufferView;
|
|
95
|
+
|
|
96
|
+
public properties_stream_int: ArrayBufferView;
|
|
97
|
+
|
|
98
|
+
// property_values_stream:
|
|
99
|
+
public properties_stream_f32_mtx_all: ArrayBufferView; // list of floats
|
|
100
|
+
public properties_stream_f32_mtx_scale_rot: ArrayBufferView; // list of floats
|
|
101
|
+
public properties_stream_f32_mtx_pos: ArrayBufferView; // list of floats
|
|
102
|
+
public properties_stream_f32_ct: ArrayBufferView; // list of floats
|
|
103
|
+
public properties_stream_strings: string[];
|
|
104
|
+
|
|
105
|
+
public properties_stream_filters: IFilter[];
|
|
106
|
+
|
|
107
|
+
public placeObjectTagsForSessionIDs: NumberMap<any>;
|
|
108
|
+
public graphicsPool: any;
|
|
109
|
+
|
|
110
|
+
public audioPool: any;
|
|
111
|
+
|
|
112
|
+
public numKeyFrames: number;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* in AS3 framescript are getting added to mc by calling "mc.addFrameScript" from within the mc.constructor
|
|
116
|
+
* because timelines are shared between all instances of a mc,
|
|
117
|
+
* only the first instance of a mc should be allowd to add framescripts to the timeline
|
|
118
|
+
* to check this, we track the id of mc-instance that adds the first framescript,
|
|
119
|
+
* and only allow additional framescripts to be added from same instance
|
|
120
|
+
**/
|
|
121
|
+
private _initalMcID: number;
|
|
122
|
+
|
|
123
|
+
constructor(readonly factory: ISceneGraphFactory) {
|
|
124
|
+
|
|
125
|
+
this._initalMcID = -1;
|
|
126
|
+
this.numKeyFrames = 0;
|
|
127
|
+
this.keyframe_indices = [];
|
|
128
|
+
this.avm1Exports = {};
|
|
129
|
+
this.avm1InitActions = {};
|
|
130
|
+
this.avm1ButtonActions = [];
|
|
131
|
+
this.graphicsPool = {};
|
|
132
|
+
this.audioPool = {};
|
|
133
|
+
this.placeObjectTagsForSessionIDs = {};
|
|
134
|
+
this._labels = {};
|
|
135
|
+
this._framescripts = {};
|
|
136
|
+
this._framescripts_translated = {};
|
|
137
|
+
this.keyframe_to_frameidx = {};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public resetScripts() {
|
|
141
|
+
this._framescripts = {};
|
|
142
|
+
this._framescripts_translated = {};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* should be called after timeline-streams have been set.
|
|
146
|
+
prepares
|
|
147
|
+
*/
|
|
148
|
+
public init(): void {
|
|
149
|
+
|
|
150
|
+
if ((this.frame_command_indices == null) || (this.frame_recipe == null) || (this.keyframe_durations == null)) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
let frame_cnt = 0;
|
|
155
|
+
let ic = 0;
|
|
156
|
+
let ic2 = 0;
|
|
157
|
+
let duration = 0;
|
|
158
|
+
let keyframe_cnt = 0;
|
|
159
|
+
let last_construct_frame = 0;
|
|
160
|
+
this.keyframe_firstframes = [];
|
|
161
|
+
this.keyframe_constructframes = [];
|
|
162
|
+
this.keyframe_indices = [];
|
|
163
|
+
this.keyframe_to_frameidx = {};
|
|
164
|
+
this.keyframe_to_frameidx[0] = 0;
|
|
165
|
+
let duration_all = 0;
|
|
166
|
+
for (ic = 0; ic < this.numKeyFrames; ic++) {
|
|
167
|
+
|
|
168
|
+
this.keyframe_to_frameidx[ic] = duration_all;
|
|
169
|
+
duration = this.keyframe_durations[(ic)];
|
|
170
|
+
duration_all += duration;
|
|
171
|
+
if (this.frame_recipe[ic] & 1)
|
|
172
|
+
last_construct_frame = keyframe_cnt;
|
|
173
|
+
|
|
174
|
+
this.keyframe_firstframes[keyframe_cnt] = frame_cnt;
|
|
175
|
+
this.keyframe_constructframes[keyframe_cnt++] = last_construct_frame;
|
|
176
|
+
|
|
177
|
+
for (ic2 = 0; ic2 < duration; ic2++)
|
|
178
|
+
this.keyframe_indices[frame_cnt++] = ic;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* for AS3:
|
|
184
|
+
* - called from constructor of MC
|
|
185
|
+
* for AS2:
|
|
186
|
+
* - called when decoding swf-tags to timeline-streams
|
|
187
|
+
* @param script -
|
|
188
|
+
* @param frame_idx - the index of the frame (not the keyframe-index)
|
|
189
|
+
* @param target_mc - the mc-instance that is calling this function
|
|
190
|
+
*/
|
|
191
|
+
public add_framescript(script: any, frame_idx: number, target_mc: MovieClip, isAVM1: boolean = false): void {
|
|
192
|
+
if (this._initalMcID >= 0 && target_mc.id != this._initalMcID)
|
|
193
|
+
return;
|
|
194
|
+
this._initalMcID = target_mc.id;
|
|
195
|
+
if (!this._framescripts[frame_idx]) {
|
|
196
|
+
this._framescripts[frame_idx] = [];
|
|
197
|
+
}
|
|
198
|
+
if (Array.isArray(script)) {
|
|
199
|
+
for (let i = 0; i < script.length; i++) {
|
|
200
|
+
this._framescripts[frame_idx][this._framescripts[frame_idx].length] = script[i];
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
this._framescripts[frame_idx].push(script);
|
|
204
|
+
}
|
|
205
|
+
this._framescripts_translated[frame_idx] = !isAVM1;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* get a array of framescripts for a specific frame
|
|
210
|
+
* for AVM1 "checkForTranslation" should be true, so we get translated framescripts
|
|
211
|
+
* @param target_mc
|
|
212
|
+
* @param frame_idx
|
|
213
|
+
* @param checkForTranslation
|
|
214
|
+
*/
|
|
215
|
+
public get_script_for_frame(
|
|
216
|
+
target_mc: MovieClip,
|
|
217
|
+
frame_idx: number,
|
|
218
|
+
checkForTranslation: boolean = false): IFrameScript[] {
|
|
219
|
+
|
|
220
|
+
if (frame_idx >= 0 && this._framescripts[frame_idx]) {
|
|
221
|
+
if (checkForTranslation && !this._framescripts_translated[frame_idx]) {
|
|
222
|
+
// todo: cleanup so we can retrieve className of target_mc without hacks
|
|
223
|
+
const name = (<any>target_mc).className ? (<any>target_mc).className : target_mc.name;
|
|
224
|
+
this._framescripts[frame_idx] = this.factory.createFrameScripts(
|
|
225
|
+
this._framescripts[frame_idx],
|
|
226
|
+
frame_idx,
|
|
227
|
+
name,
|
|
228
|
+
target_mc.id);
|
|
229
|
+
this._framescripts_translated[frame_idx] = true;
|
|
230
|
+
}
|
|
231
|
+
return this._framescripts[frame_idx];
|
|
232
|
+
}
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public get numFrames(): number {
|
|
237
|
+
return this.keyframe_indices.length;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public getKeyframeIndexForFrameIndex(frame_index: number): number {
|
|
241
|
+
return this.keyframe_indices[frame_index];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
public getChildInstance(symbolID: number, sessionID: number) {
|
|
245
|
+
return this.factory.createChildInstanceForTimeline(this, symbolID, sessionID);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
public extractHitArea(target_mc: MovieClip): DisplayObjectContainer {
|
|
249
|
+
target_mc.reset(false);
|
|
250
|
+
this.gotoFrame(target_mc, this.numFrames - 1, false);
|
|
251
|
+
let i: number = target_mc.numChildren;
|
|
252
|
+
const hitArea: DisplayObjectContainer = new DisplayObjectContainer();
|
|
253
|
+
let child: DisplayObject;
|
|
254
|
+
let originalChild: DisplayObject;
|
|
255
|
+
while (i > 0) {
|
|
256
|
+
i--;
|
|
257
|
+
originalChild = target_mc.getChildAt(i);
|
|
258
|
+
child = originalChild.clone();
|
|
259
|
+
//child.reset();
|
|
260
|
+
|
|
261
|
+
child.x = originalChild.x;
|
|
262
|
+
child.scaleX = originalChild.scaleX;
|
|
263
|
+
child.y = originalChild.y;
|
|
264
|
+
child.scaleY = originalChild.scaleY;
|
|
265
|
+
child.rotationZ = originalChild.rotationZ;
|
|
266
|
+
hitArea.addChild(child);
|
|
267
|
+
}
|
|
268
|
+
hitArea.pickObjectFromTimeline = true;
|
|
269
|
+
target_mc.pickObject = hitArea;
|
|
270
|
+
target_mc.reset(false);
|
|
271
|
+
return hitArea;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Get the label at the current frame of the target_mc MovieClip instance.
|
|
276
|
+
* If the current frame has no label, it returns null
|
|
277
|
+
* @param target_mc
|
|
278
|
+
*/
|
|
279
|
+
public getCurrentFrameLabel(target_mc: MovieClip): string {
|
|
280
|
+
const firstFrameIdxOfCurKeyFrame = this.keyframe_to_frameidx[target_mc.constructedKeyFrameIndex];
|
|
281
|
+
for (const key in this._labels) {
|
|
282
|
+
if (this._labels[key].keyFrameIndex == target_mc.constructedKeyFrameIndex &&
|
|
283
|
+
firstFrameIdxOfCurKeyFrame == target_mc.currentFrameIndex) {
|
|
284
|
+
return this._labels[key].name;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Get the label at the current frame of the target_mc MovieClip instance.
|
|
292
|
+
* If the current frame has no label it returns the name of the previous frame that includes a label.
|
|
293
|
+
* If the current frame and previous frames do not include a label, it returns null
|
|
294
|
+
* @param target_mc
|
|
295
|
+
*/
|
|
296
|
+
public getCurrentLabel(target_mc: MovieClip): string {
|
|
297
|
+
let label: string = null;
|
|
298
|
+
let lastLabelframeIdx: number = -1;
|
|
299
|
+
for (const key in this._labels) {
|
|
300
|
+
const keyIndex = this._labels[key].keyFrameIndex;
|
|
301
|
+
if (keyIndex > lastLabelframeIdx && keyIndex <= target_mc.constructedKeyFrameIndex) {
|
|
302
|
+
lastLabelframeIdx = keyIndex;
|
|
303
|
+
label = this._labels[key].name;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return label;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
public jumpToLabel(target_mc: MovieClip, label: string, offset: number = 0): void {
|
|
310
|
+
if (!this._labels[label]) {
|
|
311
|
+
console.warn('[TIMELINE] - jumpToLabel with invalid label', target_mc, label, offset);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const key_frame_index: number = this._labels[label].keyFrameIndex;
|
|
315
|
+
if (key_frame_index >= 0)
|
|
316
|
+
target_mc.currentFrameIndex = this.keyframe_firstframes[key_frame_index] + offset;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Get scripts for a specific frame
|
|
321
|
+
* atm this is only called from AVM1MovieClip._callFrame
|
|
322
|
+
* @param target_mc
|
|
323
|
+
* @param label
|
|
324
|
+
* @param isAVM1
|
|
325
|
+
*/
|
|
326
|
+
public getScriptForLabel(target_mc: MovieClip, label: string, isAVM1: boolean = false): IFrameScript[] {
|
|
327
|
+
const key_frame_index: number = this._labels[label.toLowerCase()].keyFrameIndex;
|
|
328
|
+
if (key_frame_index < 0)
|
|
329
|
+
return null;
|
|
330
|
+
const frameIdx: number = this.keyframe_firstframes[key_frame_index];
|
|
331
|
+
if (frameIdx >= 0 && this._framescripts[frameIdx]) {
|
|
332
|
+
return this.get_script_for_frame(target_mc, frameIdx, isAVM1);
|
|
333
|
+
}
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* move the playhead of the timeline to a specific frame
|
|
339
|
+
* @param target_mc
|
|
340
|
+
* @param frame_idx
|
|
341
|
+
* @param queue_script
|
|
342
|
+
* @param queue_pass2
|
|
343
|
+
* @param forceReconstruct
|
|
344
|
+
*/
|
|
345
|
+
public gotoFrame(target_mc: MovieClip, frame_idx: number,
|
|
346
|
+
queue_script: boolean = true,
|
|
347
|
+
queue_pass2: boolean = false,
|
|
348
|
+
forceReconstruct: boolean = false): void {
|
|
349
|
+
const current_keyframe_idx: number = target_mc.constructedKeyFrameIndex;
|
|
350
|
+
const target_keyframe_idx: number = this.keyframe_indices[frame_idx];
|
|
351
|
+
|
|
352
|
+
if (current_keyframe_idx == target_keyframe_idx && !forceReconstruct) {
|
|
353
|
+
(<IMovieClipAdapter>target_mc.adapter).queueFrameScripts(this, frame_idx, queue_script);
|
|
354
|
+
return;
|
|
355
|
+
} else if (current_keyframe_idx + 1 == target_keyframe_idx) {
|
|
356
|
+
// target_keyframe_idx is the next keyframe. we can just use constructnext for this
|
|
357
|
+
this.constructNextFrame(target_mc, queue_script, true);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// when constructing a frame we must start constructing
|
|
362
|
+
// either at the beginning of the timeline, or at a frame where all object was removed
|
|
363
|
+
// construct_keyframe_idx is the index of the first keyframe we must process
|
|
364
|
+
const construct_keyframe_idx: number = this.keyframe_constructframes[target_keyframe_idx];
|
|
365
|
+
|
|
366
|
+
// 3 keyframes:
|
|
367
|
+
// - current_keyframe_idx
|
|
368
|
+
// - target_keyframe_idx
|
|
369
|
+
// - construct_keyframe_idx
|
|
370
|
+
|
|
371
|
+
// normally construction must start at construct_keyframe_idx
|
|
372
|
+
// if we jump forward, and target_keyframe_idx >
|
|
373
|
+
|
|
374
|
+
let start_construct_idx: number = construct_keyframe_idx;
|
|
375
|
+
|
|
376
|
+
const jump_forward: boolean = (target_keyframe_idx > current_keyframe_idx);
|
|
377
|
+
if (jump_forward && current_keyframe_idx > construct_keyframe_idx)
|
|
378
|
+
start_construct_idx = current_keyframe_idx + 1;
|
|
379
|
+
|
|
380
|
+
(<IMovieClipAdapter>target_mc.adapter).constructFrame(this, start_construct_idx,
|
|
381
|
+
target_keyframe_idx,
|
|
382
|
+
jump_forward,
|
|
383
|
+
frame_idx,
|
|
384
|
+
queue_pass2,
|
|
385
|
+
queue_script);
|
|
386
|
+
|
|
387
|
+
// apply update commands for objects still on stage (only if they are not blocked by script)
|
|
388
|
+
this.applyCollectedUpdateCommands(target_mc);
|
|
389
|
+
|
|
390
|
+
target_mc.constructedKeyFrameIndex = target_keyframe_idx;
|
|
391
|
+
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
public applyCollectedUpdateCommands(target_mc: MovieClip): void {
|
|
395
|
+
let k: number;
|
|
396
|
+
const len: number = this._update_indices.length;
|
|
397
|
+
for (k = 0; k < len; k++)
|
|
398
|
+
this.update_childs(target_mc, this._update_indices[k], this._update_frames[k]);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* constructs the next frame of the timeline
|
|
403
|
+
* expects the target_mc.currentFrameIndex to already be set to the next frame
|
|
404
|
+
* @param target_mc
|
|
405
|
+
* @param queueScript
|
|
406
|
+
* @param scriptPass1
|
|
407
|
+
*/
|
|
408
|
+
public constructNextFrame(target_mc: MovieClip, queueScript: boolean = true, scriptPass1: boolean = false): void {
|
|
409
|
+
const frameIndex: number = target_mc.currentFrameIndex;
|
|
410
|
+
const new_keyFrameIndex: number = this.keyframe_indices[frameIndex];
|
|
411
|
+
|
|
412
|
+
if (queueScript)
|
|
413
|
+
(<IMovieClipAdapter>target_mc.adapter).queueFrameScripts(this, frameIndex, scriptPass1);
|
|
414
|
+
|
|
415
|
+
if (target_mc.constructedKeyFrameIndex != new_keyFrameIndex) {
|
|
416
|
+
target_mc.constructedKeyFrameIndex = new_keyFrameIndex;
|
|
417
|
+
|
|
418
|
+
let frame_command_idx = this.frame_command_indices[new_keyFrameIndex];
|
|
419
|
+
const frame_recipe = this.frame_recipe[new_keyFrameIndex];
|
|
420
|
+
|
|
421
|
+
if (frame_recipe & 1) {
|
|
422
|
+
(<IMovieClipAdapter>target_mc.adapter).removeAllTimelineChilds();
|
|
423
|
+
} else if (frame_recipe & 2) {
|
|
424
|
+
this.remove_childs_continous(target_mc, frame_command_idx++);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
if (frame_recipe & 4)
|
|
428
|
+
this.add_childs_continous(target_mc, frame_command_idx++);
|
|
429
|
+
|
|
430
|
+
if (frame_recipe & 8)
|
|
431
|
+
this.update_childs(target_mc, frame_command_idx++);
|
|
432
|
+
|
|
433
|
+
if (frame_recipe & 16)
|
|
434
|
+
this.start_sounds(target_mc, frame_command_idx++);
|
|
435
|
+
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
public remove_childs_continous(sourceMovieClip: MovieClip, frame_command_idx: number): void {
|
|
440
|
+
const start_index: number = this.command_index_stream[frame_command_idx];
|
|
441
|
+
const end_index: number = start_index + this.command_length_stream[frame_command_idx];
|
|
442
|
+
for (let i: number = start_index; i < end_index; i++) {
|
|
443
|
+
// in avm1 we remove by depth, in avm2 we remove by sessionID
|
|
444
|
+
(<IMovieClipAdapter>sourceMovieClip.adapter).removeTimelineChildAt(this.remove_child_stream[i]);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
public add_childs_continous(target_mc: MovieClip, frame_command_idx: number): void {
|
|
449
|
+
let idx: number;
|
|
450
|
+
const start_index: number = this.command_index_stream[frame_command_idx];
|
|
451
|
+
const end_index: number = start_index + this.command_length_stream[frame_command_idx];
|
|
452
|
+
for (let i: number = start_index; i < end_index; i++) {
|
|
453
|
+
idx = i * 3;
|
|
454
|
+
if (typeof this.add_child_stream[idx] === 'undefined') {
|
|
455
|
+
console.warn('[Timeline] - add_childs_continous - could not find child-id in child_stream for idx',
|
|
456
|
+
idx, this.add_child_stream);
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
const childAsset: IAsset = this.factory.createChildInstanceForTimeline(this,
|
|
460
|
+
this.add_child_stream[idx + 2], this.add_child_stream[idx]);
|
|
461
|
+
(<IMovieClipAdapter>target_mc.adapter).addTimelineChildAtDepth(<DisplayObject>childAsset,
|
|
462
|
+
this.add_child_stream[idx + 1]);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
public start_sounds(target_mc: MovieClip, frame_command_idx: number): void {
|
|
467
|
+
const start_index: number = this.command_index_stream[frame_command_idx];
|
|
468
|
+
const end_index: number = start_index + this.command_length_stream[frame_command_idx];
|
|
469
|
+
for (let i: number = start_index; i < end_index; i++) {
|
|
470
|
+
const audioProps: any = this.audioPool[this.add_sounds_stream[i]];
|
|
471
|
+
if (audioProps) {
|
|
472
|
+
const sound: WaveAudio = audioProps.sound;
|
|
473
|
+
|
|
474
|
+
if (!sound) {
|
|
475
|
+
console.warn('[Timeline] Missing sound in audioProps!', audioProps);
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
if (audioProps.cmd == 15) {// start sound
|
|
480
|
+
target_mc.startSound(sound, audioProps.props.loopCount || 0);
|
|
481
|
+
} else if (audioProps.cmd == 16) {// stop sound
|
|
482
|
+
target_mc.stopSound(sound);
|
|
483
|
+
}
|
|
484
|
+
//console.log("start sound:", child);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
public update_childs(target_mc: MovieClip, frame_command_idx: number, frameIdx: number = -1): void {
|
|
491
|
+
|
|
492
|
+
const start = this.command_index_stream[frame_command_idx];
|
|
493
|
+
const end = start + this.command_length_stream[frame_command_idx];
|
|
494
|
+
|
|
495
|
+
for (let i = start; i < end; i++) {
|
|
496
|
+
const child = target_mc.getTimelineChildAtSessionID(this.update_child_stream[i]);
|
|
497
|
+
|
|
498
|
+
if (!child) {
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// check if the child is blocked by script for transform
|
|
503
|
+
this._blocked = !!(child._adapter && (<IDisplayObjectAdapter> child.adapter).isBlockedByScript());
|
|
504
|
+
|
|
505
|
+
const propsStart = this.update_child_props_indices_stream[i];
|
|
506
|
+
const propsEnd = propsStart + this.update_child_props_length_stream[i];
|
|
507
|
+
|
|
508
|
+
for (let p = propsStart; p < propsEnd; p++) {
|
|
509
|
+
Timeline.applyFunctionMap[this.property_type_stream[p]] (
|
|
510
|
+
this,
|
|
511
|
+
child,
|
|
512
|
+
target_mc,
|
|
513
|
+
this.property_index_stream[p]
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
public static update_mtx_all(timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, i: number): void {
|
|
520
|
+
if (timeline._blocked || (<any>child).noTimelineUpdate)
|
|
521
|
+
return;
|
|
522
|
+
|
|
523
|
+
i *= 6;
|
|
524
|
+
|
|
525
|
+
const new_matrix: Matrix3D = child.transform.matrix3D;
|
|
526
|
+
const props_stream = timeline.properties_stream_f32_mtx_all;
|
|
527
|
+
|
|
528
|
+
new_matrix._rawData[0] = props_stream[i++];
|
|
529
|
+
new_matrix._rawData[1] = props_stream[i++];
|
|
530
|
+
new_matrix._rawData[4] = props_stream[i++];
|
|
531
|
+
new_matrix._rawData[5] = props_stream[i++];
|
|
532
|
+
new_matrix._rawData[12] = props_stream[i++];
|
|
533
|
+
new_matrix._rawData[13] = props_stream[i];
|
|
534
|
+
|
|
535
|
+
child.transform.invalidateComponents();
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
public static update_colortransform(
|
|
539
|
+
timeline: Timeline,child: DisplayObject, _target_mc: MovieClip, i: number
|
|
540
|
+
): void {
|
|
541
|
+
|
|
542
|
+
if (child._adapter && (<IDisplayObjectAdapter> child.adapter).isColorTransformByScript())
|
|
543
|
+
return;
|
|
544
|
+
|
|
545
|
+
i *= 8;
|
|
546
|
+
const props_stream = timeline.properties_stream_f32_ct;
|
|
547
|
+
const new_ct = child.transform.colorTransform || (child.transform.colorTransform = new ColorTransform());
|
|
548
|
+
|
|
549
|
+
new_ct._rawData[0] = props_stream[i++];
|
|
550
|
+
new_ct._rawData[1] = props_stream[i++];
|
|
551
|
+
new_ct._rawData[2] = props_stream[i++];
|
|
552
|
+
new_ct._rawData[3] = props_stream[i++];
|
|
553
|
+
new_ct._rawData[4] = props_stream[i++];
|
|
554
|
+
new_ct._rawData[5] = props_stream[i++];
|
|
555
|
+
new_ct._rawData[6] = props_stream[i++];
|
|
556
|
+
new_ct._rawData[7] = props_stream[i];
|
|
557
|
+
|
|
558
|
+
child.transform.invalidateColorTransform();
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
public static update_masks(timeline: Timeline, child: DisplayObject, target_mc: MovieClip, i: number): void {
|
|
562
|
+
// an object could have a multiple groups of masks, in case a graphic clip was merged into the timeline
|
|
563
|
+
// this is not implemented in the runtime yet
|
|
564
|
+
// for now, a second mask-group would overwrite the first one
|
|
565
|
+
const masks: Array<DisplayObject> = [];
|
|
566
|
+
const numMasks = timeline.properties_stream_int[i++];
|
|
567
|
+
|
|
568
|
+
if (numMasks === 0) {
|
|
569
|
+
child.timelineMasks = undefined;
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
//mask may not exist if a goto command moves the playhead to a point in the timeline after
|
|
574
|
+
//one of the masks in a mask array has already been removed. Therefore a check is needed.
|
|
575
|
+
for (let m = 0; m < numMasks; m++) {
|
|
576
|
+
masks.push(target_mc.getTimelineChildAtSessionID(timeline.properties_stream_int[i + m]));
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
child.timelineMasks = masks;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
public static update_name(timeline: Timeline, child: DisplayObject, target_mc: MovieClip, i: number): void {
|
|
583
|
+
if (timeline.properties_stream_strings[i].indexOf('instance') == 0) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
(<IMovieClipAdapter>target_mc.adapter).unregisterScriptObject(child);
|
|
588
|
+
child.name = timeline.properties_stream_strings[i];
|
|
589
|
+
(<IMovieClipAdapter> target_mc.adapter).registerScriptObject(child);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
public static update_button_name(
|
|
593
|
+
timeline: Timeline, target: DisplayObject, sourceMovieClip: MovieClip, i: number
|
|
594
|
+
): void {
|
|
595
|
+
|
|
596
|
+
target.name = timeline.properties_stream_strings[i];
|
|
597
|
+
(<MovieClip> target).addButtonListeners();
|
|
598
|
+
(<IMovieClipAdapter> sourceMovieClip.adapter).registerScriptObject(target);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
public static update_visibility(_timeline: Timeline, child: DisplayObject, target_mc: MovieClip, i: number): void {
|
|
602
|
+
if (!child._adapter || !(<IDisplayObjectAdapter> child.adapter).isVisibilityByScript()) {
|
|
603
|
+
child.visible = !!i;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
public static update_mtx_scale_rot(
|
|
608
|
+
timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, i: number
|
|
609
|
+
): void {
|
|
610
|
+
|
|
611
|
+
if (timeline._blocked || (<any>child).noTimelineUpdate) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
i *= 4;
|
|
616
|
+
|
|
617
|
+
const new_matrix: Matrix3D = child.transform.matrix3D;
|
|
618
|
+
const props_stream = timeline.properties_stream_f32_mtx_scale_rot;
|
|
619
|
+
|
|
620
|
+
new_matrix._rawData[0] = props_stream[i++];
|
|
621
|
+
new_matrix._rawData[1] = props_stream[i++];
|
|
622
|
+
new_matrix._rawData[4] = props_stream[i++];
|
|
623
|
+
new_matrix._rawData[5] = props_stream[i];
|
|
624
|
+
|
|
625
|
+
child.transform.invalidateComponents();
|
|
626
|
+
|
|
627
|
+
child._invalidateHierarchicalProperty(HierarchicalProperty.SCENE_TRANSFORM);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
public static update_mtx_pos(timeline: Timeline, child: DisplayObject, target_mc: MovieClip, i: number): void {
|
|
631
|
+
if (timeline._blocked || (<any>child).noTimelineUpdate)
|
|
632
|
+
return;
|
|
633
|
+
|
|
634
|
+
i *= 2;
|
|
635
|
+
|
|
636
|
+
const new_matrix = child.transform.matrix3D;
|
|
637
|
+
|
|
638
|
+
new_matrix._rawData[12] = timeline.properties_stream_f32_mtx_pos[i++];
|
|
639
|
+
new_matrix._rawData[13] = timeline.properties_stream_f32_mtx_pos[i];
|
|
640
|
+
|
|
641
|
+
child.transform.invalidatePosition();
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
public static enable_maskmode(_timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, _i: number): void {
|
|
645
|
+
child.maskMode = true;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
public static remove_masks(_timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, _i: number): void {
|
|
649
|
+
child.timelineMasks = undefined;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
public static update_filters(timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, i: number): void {
|
|
653
|
+
const startFilter: number = timeline.properties_stream_int[i++];
|
|
654
|
+
const numFilter: number = timeline.properties_stream_int[i++];
|
|
655
|
+
const adapter = <IDisplayObjectAdapter>child.adapter;
|
|
656
|
+
|
|
657
|
+
if (numFilter === 0) {
|
|
658
|
+
adapter.updateFilters(null);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
adapter.updateFilters(
|
|
663
|
+
timeline.properties_stream_filters.slice(startFilter, startFilter + numFilter)
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
public static swap_graphics(timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, i: number): void {
|
|
668
|
+
if (!child.isAsset(Sprite)) {
|
|
669
|
+
console.warn('[Timeline] - swap_graphics - child is not a Sprite');
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
const sprite = <Sprite>child;
|
|
674
|
+
const target = <Graphics> timeline.graphicsPool[timeline.properties_stream_int[i]];
|
|
675
|
+
|
|
676
|
+
if (target.id === sprite.graphics.id) {
|
|
677
|
+
// already the same graphics
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
sprite.graphics = target;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
public static start_audio(_timeline: Timeline, _child: DisplayObject, _target_mc: MovieClip, _i: number): void {}
|
|
685
|
+
|
|
686
|
+
public static set_ratio(_timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, i: number): void {
|
|
687
|
+
if (!child.isAsset(MorphSprite)) {
|
|
688
|
+
console.warn('[Timeline] - set_ratio - child is not a MorphSprite');
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
(<MorphSprite>child).setRatio(_timeline.properties_stream_int[i] / 0xffff);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
public static update_blendmode(_timeline: Timeline, child: DisplayObject, _target_mc: MovieClip, i: number): void {
|
|
696
|
+
child.blendMode = mapBlendIdToString(i);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
public static update_rendermode(
|
|
700
|
+
_timeline: Timeline, _child: DisplayObject, _target_mc: MovieClip, i: number): void {
|
|
701
|
+
console.log('update rendermode ' + i);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
public dispose() {
|
|
705
|
+
this.keyframe_indices = [];
|
|
706
|
+
this.avm1Exports = {};
|
|
707
|
+
this.avm1InitActions = {};
|
|
708
|
+
this.avm1ButtonActions = [];
|
|
709
|
+
this.graphicsPool = {};
|
|
710
|
+
this.audioPool = {};
|
|
711
|
+
this.placeObjectTagsForSessionIDs = {};
|
|
712
|
+
this._labels = {};
|
|
713
|
+
this._framescripts = {};
|
|
714
|
+
this._framescripts_translated = {};
|
|
715
|
+
}
|
|
716
716
|
}
|