如何在字符串上列出属性并设置默认值,Error =#1069

时间:2019-04-30 03:44:02

标签: flash

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

尽我所知。

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:在buildin.as $ 0.MethodClosure上找不到属性addEventListener,并且没有默认值。       在SkillsDemo10_Scene1_fla :: MainTimeline / frame1()

1 个答案:

答案 0 :(得分:1)

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

import flash.events.Event;

addChild函数/方法还具有.x.y属性,因此类似addChild(heartInstance).x的命令也应该给出错误。 / p>

每当您addChild在屏幕上具有.x.y位置的对象时,该对象将被分类为{{3} }。

比较自己的...

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);