【问题标题】:How do you list a property on a string and set a default value, Error = #1069如何在字符串上列出属性并设置默认值,Error = #1069
【发布时间】:2019-04-30 03:44:01
【问题描述】:

我不能这样做,教科书已经过时了,我的老师一无所知,他是个流浪汉。

尽我所知。

var hits: Number = 0;

runIT.addEventListener(MouseEvent.CLICK);

function runIT(event: MouseEvent) 

{
    var heartInstance: targetMC = new targetMC

    addChild(heartInstance).x = 260(heartInstance).y = 220;

}

我希望按钮可以工作,但输出是

ReferenceError:错误 #1069:在 builtin.as$0.MethodClosure 上找不到属性 addEventListener 并且没有默认值。 在技​​能Demo10_Scene1_fla::MainTimeline/frame1()

【问题讨论】:

    标签: flash


    【解决方案1】:

    尝试在代码顶部导入事件:

    import flash.events.Event;
    

    另外,addChild 函数/方法没有.x.y 属性,所以像addChild(heartInstance).x 这样的命令也应该给出错误。

    当您addChild 某个对象在屏幕上具有某个.x.y 位置时,该对象将被分类Display Object (read about it in the AS3 manual)

    比较你自己的...

    var heartInstance: targetMC = new targetMC
    addChild(heartInstance).x = 260(heartInstance).y = 220;
    

    使用手册中的这个修改设置...

    var square :SomeThing = new SomeThing();
    square.x = 150;
    square.y = 150;
    addChild(square);
    

    修复:

    1) 一个类的新实例需要();(以表明它是一个类)...

    var heartInstance: targetMC = new targetMC();
    

    2) 你不应该这样使用:addChild(heartInstance).x = 260(heartInstance).y = 220;

    正确的设置:

    heartInstance.x = 260;
    heartInstance.y = 220;
    addChild(heartInstance);
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 2019-07-07
    • 1970-01-01
    • 1970-01-01
    • 2011-07-06
    相关资源
    最近更新 更多