私のコードを見て、このエラーが発生する理由を教えてください:
TypeError: エラー #1009: null オブジェクト参照のプロパティまたはメソッドにアクセスできません。Arm/update() で
学んだばかりで、それらを機能させることができなかったため、ドキュメントクラスを使用していません。私が始めたチュートリアルは次のとおりです。
メインコード:
stop();
import flash.events.Event;
import flash.events.MouseEvent;
var mouseIsDown = false; // mouse isn't held at start
var speed = 0; // no speed at the start
var score = 0; // start with no score!
// check for collisions every frame
addEventListener(Event.ENTER_FRAME, mainLoop);
// add 2 event listeners for the mouse button
stage.addEventListener(MouseEvent.MOUSE_DOWN, clicked);
stage.addEventListener(MouseEvent.MOUSE_UP, unclicked);
// explain the mouse functions
function clicked(m:MouseEvent) {
mouseIsDown = true;
}
function unclicked(m:MouseEvent) {
mouseIsDown = false;
}
//// explain the main game loop
function mainLoop(e:Event) {
// update the score!
score = score + 10;
// update the text field
Output.text = "Score: "+score;
// move the player based on the mouse button
if (mouseIsDown) {
// take something off the speed
speed -= 2; // accelerate upwards
} else {
speed += 2;
}
// limit the speed
if (speed > 10) speed = 10;
if (speed < -10) speed = -10;
// move the player based on the speed
firefly.y += speed;
// loop through everything on screen
for (var i = 0; i<numChildren; i++) {
// check to see if this object is a block
if (getChildAt(i) is Block || getChildAt(i) is Boundary || getChildAt(i) is Block2 || getChildAt(i) is Arm) {
var b = getChildAt(i) as MovieClip;
// this means the object is a block
// check the block against the player object
if (b.hitTestObject(firefly)) {
// make an explosion
for (var counter = 0; counter<12; counter++) {
// make a new Boom object
var boom = new Boom();
boom.x = firefly.x;
boom.y = firefly.y;
// randomly rotate boom
boom.rotation = Math.random()*360;
// randomly scale it
boom.scaleX = boom.scaleY = 0.5+Math.random();
// add the boom to the world
addChild(boom);
}
// hide the player
firefly.visible = false;
removeEventListener(Event.ENTER_FRAME, mainLoop);
if(b.hitTestObject(firefly)){
nextFrame();
}
}
}
}
}