avm2: Throw proper error when setting name of timeline objects
This commit is contained in:
parent
5ee6218ab4
commit
4219f39668
|
@ -210,6 +210,17 @@ pub fn verify_error<'gc>(
|
||||||
error_constructor(activation, class, message, code)
|
error_constructor(activation, class, message, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(never)]
|
||||||
|
#[cold]
|
||||||
|
pub fn illegal_operation_error<'gc>(
|
||||||
|
activation: &mut Activation<'_, 'gc>,
|
||||||
|
message: &str,
|
||||||
|
code: u32,
|
||||||
|
) -> Result<Value<'gc>, Error<'gc>> {
|
||||||
|
let class = activation.avm2().classes().illegaloperationerror;
|
||||||
|
error_constructor(activation, class, message, code)
|
||||||
|
}
|
||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[cold]
|
#[cold]
|
||||||
pub fn io_error<'gc>(
|
pub fn io_error<'gc>(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! `flash.display.DisplayObject` builtin/prototype
|
//! `flash.display.DisplayObject` builtin/prototype
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::error::{argument_error, make_error_2008};
|
use crate::avm2::error::{argument_error, illegal_operation_error, make_error_2008};
|
||||||
use crate::avm2::filters::FilterAvm2Ext;
|
use crate::avm2::filters::FilterAvm2Ext;
|
||||||
use crate::avm2::object::{Object, TObject};
|
use crate::avm2::object::{Object, TObject};
|
||||||
use crate::avm2::parameters::ParametersExt;
|
use crate::avm2::parameters::ParametersExt;
|
||||||
|
@ -490,10 +490,11 @@ pub fn set_name<'gc>(
|
||||||
let new_name = args.get_string(activation, 0)?;
|
let new_name = args.get_string(activation, 0)?;
|
||||||
|
|
||||||
if dobj.instantiated_by_timeline() {
|
if dobj.instantiated_by_timeline() {
|
||||||
return Err(format!(
|
return Err(Error::AvmError(illegal_operation_error(
|
||||||
"Display object {new_name} was placed by the timeline and cannot have it's name changed.",
|
activation,
|
||||||
)
|
"Error #2078: The name property of a Timeline-placed object cannot be modified.",
|
||||||
.into());
|
2078,
|
||||||
|
)?));
|
||||||
}
|
}
|
||||||
|
|
||||||
dobj.set_name(activation.context.gc_context, new_name);
|
dobj.set_name(activation.context.gc_context, new_name);
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
// circle.
|
||||||
|
_level0.circle
|
||||||
|
|
||||||
|
// circle._name
|
||||||
|
circle
|
||||||
|
|
||||||
|
// circle._name = "square"
|
||||||
|
|
||||||
|
// circle
|
||||||
|
undefined
|
||||||
|
|
||||||
|
// square
|
||||||
|
_level0.square
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
||||||
|
num_frames = 1
|
|
@ -0,0 +1,62 @@
|
||||||
|
package {
|
||||||
|
|
||||||
|
import flash.display.MovieClip;
|
||||||
|
import flash.utils.describeType;
|
||||||
|
import flash.display.Sprite;
|
||||||
|
|
||||||
|
|
||||||
|
public class Test extends MovieClip {
|
||||||
|
|
||||||
|
|
||||||
|
public function Test() {
|
||||||
|
trace("// circle.");
|
||||||
|
trace(circle);
|
||||||
|
trace("");
|
||||||
|
|
||||||
|
trace("// circle.name");
|
||||||
|
trace(circle.name);
|
||||||
|
trace("");
|
||||||
|
|
||||||
|
trace("// circle.name = \"square\"");
|
||||||
|
try {
|
||||||
|
circle.name = "square";
|
||||||
|
} catch (e) {
|
||||||
|
trace(e);
|
||||||
|
}
|
||||||
|
trace("");
|
||||||
|
|
||||||
|
trace("// circle");
|
||||||
|
trace(circle);
|
||||||
|
trace("");
|
||||||
|
|
||||||
|
trace("// circle.name");
|
||||||
|
trace(circle.name);
|
||||||
|
trace("");
|
||||||
|
|
||||||
|
trace("// removeChild(circle)");
|
||||||
|
removeChild(circle);
|
||||||
|
trace("");
|
||||||
|
|
||||||
|
trace("// circle.name = \"square\"");
|
||||||
|
try {
|
||||||
|
circle.name = "square";
|
||||||
|
} catch (e) {
|
||||||
|
trace(e);
|
||||||
|
}
|
||||||
|
trace("");
|
||||||
|
|
||||||
|
trace("// addChild(circle)");
|
||||||
|
addChild(circle);
|
||||||
|
trace("");
|
||||||
|
|
||||||
|
trace("// circle.name = \"square\"");
|
||||||
|
try {
|
||||||
|
circle.name = "square";
|
||||||
|
} catch (e) {
|
||||||
|
trace(e);
|
||||||
|
}
|
||||||
|
trace("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
// circle.
|
||||||
|
[object MovieClip]
|
||||||
|
|
||||||
|
// circle.name
|
||||||
|
circle
|
||||||
|
|
||||||
|
// circle.name = "square"
|
||||||
|
Error: Error #2078: The name property of a Timeline-placed object cannot be modified.
|
||||||
|
|
||||||
|
// circle
|
||||||
|
[object MovieClip]
|
||||||
|
|
||||||
|
// circle.name
|
||||||
|
circle
|
||||||
|
|
||||||
|
// removeChild(circle)
|
||||||
|
|
||||||
|
// circle.name = "square"
|
||||||
|
Error: Error #2078: The name property of a Timeline-placed object cannot be modified.
|
||||||
|
|
||||||
|
// addChild(circle)
|
||||||
|
|
||||||
|
// circle.name = "square"
|
||||||
|
Error: Error #2078: The name property of a Timeline-placed object cannot be modified.
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
||||||
|
num_frames = 1
|
Loading…
Reference in New Issue