avm1: Require a `MovieClip` in `MovieClip.duplicateMovie`
A `MovieClip` must be instantiated from an ID of a `MovieClip`.
This commit is contained in:
parent
fd76f67bd2
commit
d3c6d9d148
|
@ -849,28 +849,26 @@ pub fn duplicate_movie_clip_with_bias<'gc>(
|
||||||
return Ok(Value::Undefined);
|
return Ok(Value::Undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
let id = movie_clip.id();
|
|
||||||
let movie = parent
|
let movie = parent
|
||||||
.movie()
|
.movie()
|
||||||
.or_else(|| activation.base_clip().movie())
|
.or_else(|| activation.base_clip().movie())
|
||||||
.unwrap_or_else(|| activation.context.swf.clone());
|
.unwrap_or_else(|| activation.context.swf.clone());
|
||||||
let new_clip = if movie_clip.id() != 0 {
|
let new_clip = if movie_clip.id() != 0 {
|
||||||
// Clip from SWF; instantiate a new copy.
|
// Clip from SWF; instantiate a new copy.
|
||||||
activation
|
let library = activation.context.library.library_for_movie(movie).unwrap();
|
||||||
.context
|
library
|
||||||
.library
|
.instantiate_by_id(movie_clip.id(), activation.context.gc_context)
|
||||||
.library_for_movie(movie)
|
.unwrap()
|
||||||
.ok_or("Movie is missing!")
|
.as_movie_clip()
|
||||||
.and_then(|l| l.instantiate_by_id(id, activation.context.gc_context))
|
.unwrap()
|
||||||
} else {
|
} else {
|
||||||
// Dynamically created clip; create a new empty movie clip.
|
// Dynamically created clip; create a new empty movie clip.
|
||||||
Ok(MovieClip::new(movie, activation.context.gc_context).into())
|
MovieClip::new(movie, activation.context.gc_context)
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Ok(new_clip) = new_clip {
|
|
||||||
// Set name and attach to parent.
|
// Set name and attach to parent.
|
||||||
new_clip.set_name(activation.context.gc_context, new_instance_name);
|
new_clip.set_name(activation.context.gc_context, new_instance_name);
|
||||||
parent.replace_at_depth(&mut activation.context, new_clip, depth);
|
parent.replace_at_depth(&mut activation.context, new_clip.into(), depth);
|
||||||
|
|
||||||
// Copy display properties from previous clip to new clip.
|
// Copy display properties from previous clip to new clip.
|
||||||
let matrix = *movie_clip.base().matrix();
|
let matrix = *movie_clip.base().matrix();
|
||||||
|
@ -880,10 +878,7 @@ pub fn duplicate_movie_clip_with_bias<'gc>(
|
||||||
new_clip.set_color_transform(activation.context.gc_context, color_transform);
|
new_clip.set_color_transform(activation.context.gc_context, color_transform);
|
||||||
|
|
||||||
let clip_actions = movie_clip.clip_actions().to_vec();
|
let clip_actions = movie_clip.clip_actions().to_vec();
|
||||||
new_clip
|
new_clip.set_clip_event_handlers(activation.context.gc_context, clip_actions);
|
||||||
.as_movie_clip()
|
|
||||||
.unwrap()
|
|
||||||
.set_clip_event_handlers(activation.context.gc_context, clip_actions);
|
|
||||||
|
|
||||||
*new_clip.as_drawing(activation.context.gc_context).unwrap() = movie_clip
|
*new_clip.as_drawing(activation.context.gc_context).unwrap() = movie_clip
|
||||||
.as_drawing(activation.context.gc_context)
|
.as_drawing(activation.context.gc_context)
|
||||||
|
@ -900,15 +895,7 @@ pub fn duplicate_movie_clip_with_bias<'gc>(
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(new_clip.object().coerce_to_object(activation).into())
|
Ok(new_clip.object())
|
||||||
} else {
|
|
||||||
avm_warn!(
|
|
||||||
activation,
|
|
||||||
"Unable to duplicate clip '{}'",
|
|
||||||
movie_clip.name()
|
|
||||||
);
|
|
||||||
Ok(Value::Undefined)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_bytes_loaded<'gc>(
|
fn get_bytes_loaded<'gc>(
|
||||||
|
|
Loading…
Reference in New Issue