我做不到,这本教科书已经过时了,我的老师一无所知,因为他是个流浪汉。
尽我所知。
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()
答案 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);