From 5ccc057f0f36059b8f5e7a9d7e8f579ddd62963b Mon Sep 17 00:00:00 2001 From: nosamu <71368227+n0samu@users.noreply.github.com> Date: Tue, 14 Nov 2023 21:23:08 -0600 Subject: [PATCH] Stop execution of actions if clip is removed --- lib/interpreter.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/interpreter.ts b/lib/interpreter.ts index 8a89615..b583f3d 100644 --- a/lib/interpreter.ts +++ b/lib/interpreter.ts @@ -293,6 +293,14 @@ function isAVM1MovieClip(obj): boolean { obj instanceof AVM1MovieClip; } +// Removing a movieclip should stop the execution of its actions immediately +function stopIfClipRemoved(ectx: ExecutionContext, clip: AVM1Object | AVM1Function) { + if (isAVM1MovieClip(clip) && clip.isGhost) { + console.log("Stopping actions for ghost clip"); + ectx.isEndOfActions = true; + } +} + function as2GetType(v): string { if (v === null) { return 'null'; @@ -2233,6 +2241,7 @@ function avm1_callableHelper(ectx: ExecutionContext, obj: AVM1Object | AVM1Funct } frame.resetCallee(); + stopIfClipRemoved(ectx, obj); return { result, called }; }