avm2: Implement the programmatically-playing flag that governs `isPlaying` behavior.
This commit is contained in:
parent
035c841eb5
commit
50dd9a6733
|
@ -278,7 +278,7 @@ pub fn is_playing<'gc>(
|
|||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
{
|
||||
return Ok(mc.playing().into());
|
||||
return Ok((mc.programmatically_played() && mc.playing()).into());
|
||||
}
|
||||
|
||||
Ok(Value::Undefined)
|
||||
|
@ -310,6 +310,7 @@ pub fn goto_and_play<'gc>(
|
|||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
{
|
||||
mc.set_programmatically_played(activation.context.gc_context);
|
||||
goto_frame(activation, mc, args, false)?;
|
||||
}
|
||||
|
||||
|
@ -396,6 +397,7 @@ pub fn play<'gc>(
|
|||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
{
|
||||
mc.set_programmatically_played(activation.context.gc_context);
|
||||
mc.play(&mut activation.context);
|
||||
}
|
||||
|
||||
|
|
|
@ -588,6 +588,14 @@ impl<'gc> MovieClip<'gc> {
|
|||
self.0.read().playing()
|
||||
}
|
||||
|
||||
pub fn programmatically_played(self) -> bool {
|
||||
self.0.read().programmatically_played()
|
||||
}
|
||||
|
||||
pub fn set_programmatically_played(self, mc: MutationContext<'gc, '_>) {
|
||||
self.0.write(mc).set_programmatically_played()
|
||||
}
|
||||
|
||||
pub fn next_frame(self, context: &mut UpdateContext<'_, 'gc, '_>) {
|
||||
if self.current_frame() < self.total_frames() {
|
||||
self.goto_frame(context, self.current_frame() + 1, true);
|
||||
|
@ -1877,6 +1885,14 @@ impl<'gc> MovieClipData<'gc> {
|
|||
}
|
||||
}
|
||||
|
||||
fn programmatically_played(&self) -> bool {
|
||||
self.flags.contains(MovieClipFlags::ProgrammaticallyPlayed)
|
||||
}
|
||||
|
||||
fn set_programmatically_played(&mut self) {
|
||||
self.flags.insert(MovieClipFlags::ProgrammaticallyPlayed);
|
||||
}
|
||||
|
||||
fn first_child(&self) -> Option<DisplayObject<'gc>> {
|
||||
self.base.first_child()
|
||||
}
|
||||
|
@ -3100,6 +3116,12 @@ enum MovieClipFlags {
|
|||
|
||||
/// Whether this `MovieClip` is playing or stopped.
|
||||
Playing,
|
||||
|
||||
/// Whether this `MovieClip` has been played as a result of an AS3 command.
|
||||
///
|
||||
/// The AS3 `isPlaying` property is broken and yields false until you first
|
||||
/// call `play` to unbreak it. This flag tracks that bug.
|
||||
ProgrammaticallyPlayed,
|
||||
}
|
||||
|
||||
/// Actions that are attached to a `MovieClip` event in
|
||||
|
|
|
@ -9,8 +9,6 @@ frame1
|
|||
[object FrameLabel],[object FrameLabel]
|
||||
//currentScene
|
||||
[object Scene]
|
||||
//enabled
|
||||
true
|
||||
//framesLoaded
|
||||
4
|
||||
//isPlaying
|
||||
|
@ -19,8 +17,7 @@ false
|
|||
[object Scene],[object Scene]
|
||||
//totalFrames
|
||||
4
|
||||
//trackAsMenu
|
||||
false
|
||||
undefined
|
||||
//Frame 2, Scene 1
|
||||
//currentFrame
|
||||
2
|
||||
|
@ -32,18 +29,14 @@ frame1
|
|||
[object FrameLabel],[object FrameLabel]
|
||||
//currentScene
|
||||
[object Scene]
|
||||
//enabled
|
||||
true
|
||||
//framesLoaded
|
||||
4
|
||||
//isPlaying
|
||||
false
|
||||
true
|
||||
//scenes
|
||||
[object Scene],[object Scene]
|
||||
//totalFrames
|
||||
4
|
||||
//trackAsMenu
|
||||
false
|
||||
//Frame 3, Scene 1
|
||||
//currentFrame
|
||||
3
|
||||
|
@ -55,18 +48,14 @@ frame3
|
|||
[object FrameLabel],[object FrameLabel]
|
||||
//currentScene
|
||||
[object Scene]
|
||||
//enabled
|
||||
true
|
||||
//framesLoaded
|
||||
4
|
||||
//isPlaying
|
||||
false
|
||||
true
|
||||
//scenes
|
||||
[object Scene],[object Scene]
|
||||
//totalFrames
|
||||
4
|
||||
//trackAsMenu
|
||||
false
|
||||
//Frame 1, Scene 2
|
||||
//currentFrame
|
||||
1
|
||||
|
@ -78,15 +67,13 @@ frame4
|
|||
[object FrameLabel]
|
||||
//currentScene
|
||||
[object Scene]
|
||||
//enabled
|
||||
true
|
||||
//framesLoaded
|
||||
4
|
||||
//isPlaying
|
||||
false
|
||||
true
|
||||
//scenes
|
||||
[object Scene],[object Scene]
|
||||
//totalFrames
|
||||
4
|
||||
//trackAsMenu
|
||||
//isPlaying
|
||||
false
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue