zoukankan      html  css  js  c++  java
  • actionscript3 Error: Attempt to delete the fixed property loader. Only dynamically defined properties can be deleted.

    今天在写一段代码的时候,编译出现这个错误:

    Error: Attempt to delete the fixed property loader.  Only dynamically defined properties can be deleted.

    查阅相关资料才知道在actionscirpt 3 中delete只能删除动态类中动态声明的属性。

    在actionscirpt 3中开始支持运行时sealed class,没有用dynamic关键字声明的类都是sealed class(这里要避免和C#里的sealed关键字混淆,c#里的sealed关键字表示这个类无法被继承)。sealed class(或者他的实例)都无法在运行时添加或者删除他们定义的属性。因此按照ECMAScript规范,delete将只能删除动态类动态创建的属性,甚至无法删除方法级的变量。

    如果试图用delete关键字删除动态属性以外的东西,将得到一个编译时错误(strict mode),看起来想这样:

    Error: Attempt to delete the fixed property loader.  Only dynamically defined properties can be deleted.

    在as3中,delete关键字会返回一个bool值来标识操作是否成功。(如果成功,那么这个属性将不再存在)

    可以编写以下这样的代码来测试

    var t:* = new Timer(15); 
    trace(delete(t.delay)); // traces false, object is sealed so can't delete
    trace(t.delay); // 15 - delete never occurred
    var o:* = {fun:"stuff"};
    trace(delete(o.fun)); // traces true, object is dynamic so can delete
    trace(o.fun); // undefined - delete occurred
    trace(delete(o.foo)); // true, because foo is not defined after delete
    

  • 相关阅读:
    [swustoj 1021] Submissions of online judge
    [swustoj 404] 最小代价树
    [swustoj 917] K-lucky-number
    [swustoj 183] 种树
    [LA 3887] Slim Span
    [ahu 1248] NBA Finals
    用js获取当前月份的天数
    WampServer
    jquery checkbox选中、改变状态、change和click事件
    为什么排版引擎解析 CSS 选择器时一定要从右往左解析?
  • 原文地址:https://www.cnblogs.com/alexlee85/p/1936719.html
Copyright © 2011-2022 走看看