-
hitTestObject problem.
I am converting a as2 file to as3. I am trying to convert this. I tried this:
for (var a:uint=1; a<=10; a++) {
if (player.hitTestObject(root.["wall"+a]) == true) {
player.x += 0;
}
}
but i get this error.
TypeError: Error #2007: Parameter hitTestObject must be non-null.
at flash.display::DisplayObject/flash.display:DisplayObject::_hitTest()
at flash.display::DisplayObject/hitTestObject()
at MyFile_fla::MainTimeline/onEnterFrame()
-
Although why you'd want to += 0 is beyond me...
PHP Code:
for(var a:uint = 1; a < 10; a++){
if(player.hitTestObject(root['wall' + a])) player.x += 0;
}
-
I used +=0 to stop movement... I should use = 0....
but i changed to code and i still get that error
-
doh...my bad - I copied that wrong - you need the version with getChild in it :P
PHP Code:
for(var a:uint = 1; a < 10; a++){
if (player.hitTestObject(getChildByName('wall'+a))) player.x = 0;
}
assuming you are executing on the root level...otherwise root.getChildByName...