avm1: Correct depth calculation for AVM1 clips pending removal and add tests
This commit is contained in:
parent
6b6e07c7cb
commit
48f4df51a5
|
@ -12,7 +12,7 @@ mod callable_value;
|
|||
mod debug;
|
||||
mod error;
|
||||
mod fscommand;
|
||||
mod globals;
|
||||
pub(crate) mod globals;
|
||||
mod object;
|
||||
mod property;
|
||||
mod property_map;
|
||||
|
|
|
@ -1168,7 +1168,7 @@ pub fn create_globals<'gc>(
|
|||
/// The depth of objects placed on the timeline in the Flash IDE start from 0 in the SWF,
|
||||
/// but are negative when queried from MovieClip.getDepth().
|
||||
/// Add this to convert from AS -> SWF depth.
|
||||
const AVM_DEPTH_BIAS: i32 = 16384;
|
||||
pub const AVM_DEPTH_BIAS: i32 = 16384;
|
||||
|
||||
/// The maximum depth that the AVM will allow you to swap or attach clips to.
|
||||
/// What is the derivation of this number...?
|
||||
|
|
|
@ -915,7 +915,8 @@ impl<'gc> ChildContainer<'gc> {
|
|||
}
|
||||
|
||||
let cur_depth = child.depth();
|
||||
child.set_depth(context.gc_context, -cur_depth);
|
||||
// Note that the depth returned by AS will be offset by the `AVM_DEPTH_BIAS`, so this is really `-(cur_depth+1+AVM_DEPTH_BIAS)`
|
||||
child.set_depth(context.gc_context, -cur_depth - 1);
|
||||
|
||||
if let Some(mc) = child.as_movie_clip() {
|
||||
// Clip events should still fire
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
Frame 1:
|
||||
clip.depth = -16383
|
||||
clip2.depth = -16381
|
||||
clip3.depth = 0
|
||||
clip4.depth = 1
|
||||
clip5.depth = -16379
|
||||
clip = _level0.clip
|
||||
clip._x = 125.5
|
||||
clip2 = _level0.clip2
|
||||
|
@ -15,6 +20,10 @@ clip2 = undefined
|
|||
clip3 = undefined
|
||||
clip4 = undefined
|
||||
clip5 = _level0.clip5
|
||||
clip.depth = -16386
|
||||
clip2.depth = undefined
|
||||
Fixme(5492)
|
||||
clip5.depth = -16390
|
||||
End frame 2
|
||||
unload clipEvent
|
||||
unload clipEvent 2
|
||||
|
@ -25,12 +34,19 @@ clip2 = undefined
|
|||
clip3 = undefined
|
||||
clip4 = undefined
|
||||
clip5 = undefined
|
||||
clip.depth = -16386
|
||||
clip2.depth = undefined
|
||||
Fixme(5492)
|
||||
clip5.depth = undefined
|
||||
End frame 3
|
||||
Frame 4
|
||||
clip = undefined
|
||||
clip._x = undefined
|
||||
clip2 = undefined
|
||||
clip3 = undefined
|
||||
clip4 = undefined
|
||||
Fixme(5492)
|
||||
clip5 = undefined
|
||||
clip.depth = undefined
|
||||
clip2.depth = undefined
|
||||
Fixme(5492)
|
||||
clip5.depth = undefined
|
||||
End frame 4
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue