title: Phaser.js : cannot read property '0' on tiled map layer
body: <p>I'm working with Paser.js on a Meteor.js server.</p>
  
  <p>It worked wperfectly until I try to use tiled maps as described <a href="http://blog.hovercraft.ie/post/119437806421/creating-a-platformer-tilemap-for-phaser" rel="noreferrer">here</a>.</p>
  
  <p>Here is my code :</p>
  
  <p>JS :</p>
  
  <pre><code>    if (Meteor.isClient) {
    Template.Game.onCreated(function()
    {
      var game = new Phaser.Game(800, 600, Phaser.AUTO, '', {
         preload: preload,
         create: create,
         update: update
      });
      var map;
      var backgroundLayer;
      var blockLayer;
      var bg;
  function preload()
  {
    // load all game assets
    // images, spritesheets, atlases, audio etc..
    game.load.tilemap('myTilemap', 'assets/tilemaps/scifi.json', null, Phaser.Tilemap.TILED_JSON);
    game.load.image('myTileset', "assets/tilemaps/scifi_platformTiles_32x32.png");
  }
  
  function create()
  {
    map = game.add.tilemap('myTilemap');
    map.addTilesetImage('scifi_platformTiles_32x32', 'myTileset');
  
    backgroundLayer = map.createLayer('background');
    blockLayer = map.createLayer('blocklayer');
  }
  
  function update()
  {
  
  }
    });
  }
  </code></pre>
  
  <p>HTML :</p>
  
  <pre><code>&lt;head&gt;
      &lt;meta charset="UTF-8" /&gt;
      &lt;title&gt;Phaser - Making your first game, part 1&lt;/title&gt;
      &lt;script type="text/javascript" src="phaser.min.js"&gt;&lt;/script&gt;
      &lt;style type="text/css"&gt;
          body {
              margin: 0;
          }
      &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;h1&gt;Welcome to my first Phaser game!&lt;/h1&gt;
  
    {{&gt; Game}}
  &lt;/body&gt;
  
  &lt;template name="Game"&gt;
    &lt;div id="phaserCanvas"&gt;&lt;/div&gt;
  &lt;/template&gt;
  </code></pre>
  
  <p>And, when I try it on localhost:3000, I get :</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property '0' of undefined</p>
  </blockquote>
  
  <p>From phaser.min.js:15. The line which generate that warning is </p>
  
  <pre><code>blockLayer = map.createLayer('blocklayer');
  </code></pre>
  
  <p>It seems that phaser can correctly read the <code>'background'</code> layer information from the scifi.json, but not the <code>'blocklayer'</code> one.</p>
  
  <p>Here is an extract from the scifi.json :</p>
  
  <pre><code>{ "height":20,
   "layers":[
          {
           "compression":"zlib",
           "data": "[Some very long hashed key...]",
           "encoding":"base64",
           "height":20,
           "name":"background",
           "opacity":1,
           "type":"tilelayer",
           "visible":true,
           "width":20,
           "x":0,
           "y":0
          }, 
          {
           "compression":"zlib",
           "data":"[Some very long hashed key...]",
           "encoding":"base64",
           "height":20,
           "name":"blocklayer",
           "opacity":1,
           "type":"tilelayer",
           "visible":true,
           "width":20,
           "x":0,
           "y":0
          }],
   "nextobjectid":1,
  [...]
  </code></pre>
  
  <p>And I'm stil unable to find out what's the problem... Has anyone faced that before ?</p>
  
  <p>More informations :</p>
  
  <ul>
  <li><p>I use Atom as IDE</p></li>
  <li><p>I tried with Phaser v2.0.1 and Phaser v2.4.2</p></li>
  </ul>
  
  <p>Thanks you.</p>