avm2+tests: Support primitives besides null in MovieClip.addFrameScript; add test

This commit is contained in:
Lord-McSweeney 2023-06-13 20:47:47 -07:00 committed by Adrian Wielgosik
parent 202fe2f1bb
commit 6006aa82c2
6 changed files with 10 additions and 8 deletions

View File

@ -23,11 +23,7 @@ pub fn add_frame_script<'gc>(
{
for (frame_id, callable) in args.chunks_exact(2).map(|s| (s[0], s[1])) {
let frame_id = frame_id.coerce_to_u32(activation)? as u16 + 1;
let callable = if callable == Value::Null {
None
} else {
Some(callable.as_callable(activation, None, None)?)
};
let callable = callable.as_callable(activation, None, None).ok();
mc.register_frame_script(frame_id, callable, &mut activation.context);
}

View File

@ -7,7 +7,9 @@
public function Test() {
addFrameScript(0, frame1, 1, frame2a, 1, frame2b, 2, frame3, 2, null, 3, frame4);
addFrameScript(1, undefined);
addFrameScript(0, frame1, 1, frame2a, 1, frame2b, 2, frame3, 2, null, 3, frame4, 4, frame5);
addFrameScript(3, "primitive");
}
function frame1() {
@ -28,6 +30,10 @@
function frame4() {
trace("Frame 4");
}
function frame5() {
trace("Frame 5");
stop();
}
}

View File

@ -1,3 +1,3 @@
Frame 1
Frame 2b
Frame 4
Frame 5

View File

@ -1 +1 @@
num_frames = 4
num_frames = 5