【发布时间】:2015-12-27 01:38:28
【问题描述】:
所以基本上我想让一个男孩吃掉一些使用 addChild 生成的蘑菇。我为它做了一个热门测试。但我有一个未定义属性的错误 1120。我怎么能解决这个问题?任何帮助将不胜感激。
这是我的代码。
var timer:Timer = new Timer(1000,10);
timer.addEventListener(TimerEvent.TIMER, addTarget);
timer.start();
var score:int = 0;
function addTarget(e:TimerEvent)
{
var posX = Math.random()*860;
var posY = Math.random()*500;
var mushroom:Mushroom = new Mushroom();
addChild(mushroom);
mushroom.x = posX;
mushroom.y = posY;
boy_mc.addEventListener(Event.ENTER_FRAME, scoring);
}
function scoring(e:Event)
{
trace("test");
if (boy_mc.hitTestObject(mushroom))
{
score = score + (MovieClip(e.currentTarget).point);
score_txt.text = String(score);
}
}
----------------这是我的类文件----------
package
{
import flash.display.MovieClip;
public class Mushroom extends MovieClip
{
private var size:Number;
public var point:int;
public var mushroom:int;
public function Mushroom()
{
// constructor code
size = (Math.random()*100)+20;
this.width = size;
this.height = size;
point = Math.random()*10;
}
}
}
【问题讨论】:
-
error :is on this " if (boy_mc.hitTestObject(mushroom))"未定义属性蘑菇的访问。
-
为了完成,您应该通过编辑将错误消息添加到问题本身
标签: actionscript-3 flash actionscript adobe