Note that there are some explanatory texts on larger screens.

plurals
  1. POAS3 - TypeError: Error #1009
    primarykey
    data
    text
    <p>I'm trying to create a system that puts each block in a block Array which I can use to easily add blocks to the stage via XML, however I'm getting </p> <pre><code>[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference. </code></pre> <p>When it initializes the 'blockStone'.</p> <p>Here's my main Block class, each block is initialized here.</p> <pre><code>package com.snakybo.platformengine.block { import flash.display.MovieClip; public class Block extends MovieClip { public static var blockList:Array = []; public static const blockStone:Block = (new BlockStone(0)); public var blockID:int; private var mc:MovieClip; public function Block(blockID:int, mc:MovieClip) { if (blockList[blockID] != null) { throw new Error("Slot " + blockID + " is already occupied by " + blockList[blockID] + " when adding " + this); } else { blockList[blockID] = this; this.blockID = blockID; this.mc = mc; mc.x = 100; mc.y = 100; addChild(mc); } } } } </code></pre> <p>Here's the BlockStone class:</p> <pre><code>package com.snakybo.platformengine.block { public class BlockStone extends Block { public function BlockStone(blockID:int) { super(blockID, new stone()); } } } </code></pre> <p>FlashDevelop refers to this line when it errors:</p> <pre><code>public class BlockStone extends Block { </code></pre> <p>Here's the stack trace:</p> <pre><code>TypeError: Error #1009: Cannot access a property or method of a null object reference. at global$init()[C:\Users\Kevin\Desktop\Extra\Code\Actionscript\PlatformEngine\src\com\snakybo\platformengine\block\BlockStone.as:3] at com.snakybo.platformengine.block::Block$cinit() at global$init()[C:\Users\Kevin\Desktop\Extra\Code\Actionscript\PlatformEngine\src\com\snakybo\platformengine\block\Block.as:5] at com.snakybo.platformengine::Game()[C:\Users\Kevin\Desktop\Extra\Code\Actionscript\PlatformEngine\src\com\snakybo\platformengine\Game.as:13] at com.snakybo.platformengine::Main/init()[C:\Users\Kevin\Desktop\Extra\Code\Actionscript\PlatformEngine\src\com\snakybo\platformengine\Main.as:20] at com.snakybo.platformengine::Main()[C:\Users\Kevin\Desktop\Extra\Code\Actionscript\PlatformEngine\src\com\snakybo\platformengine\Main.as:11] </code></pre> <p>I'm pretty sure it's a problem with AS3, since this method works in Java. I'm open to suggestions on better ways to do this in AS3 using block ID's defined in an XML file.</p> <p>Can anyone explain why this is happening? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload