Can't run my game using tiled maps

Hello guys,

I’m having trouble with tiled maps made by Tiled. Every time that I tried to load a map, this error occur:

Uncaught TypeError: Cannot call method 'getAttribute' of undefined (02:19:38:666 | error, javascript) at cc.TMXMapInfo.cc.SAXParser.extend.parseXMLFile (public_html/lib/Cocos2d-html5-v2.0.min.js:817:527) at cc.TMXMapInfo.cc.SAXParser.extend.initWithTMXFile (public_html/lib/Cocos2d-html5-v2.0.min.js:814:492) at cc.TMXMapInfo.create (public_html/lib/Cocos2d-html5-v2.0.min.js:824:429) at cc.TMXTiledMap.cc.Node.extend.initWithTMXFile (public_html/lib/Cocos2d-html5-v2.0.min.js:804:305) at cc.TMXTiledMap.create (public_html/lib/Cocos2d-html5-v2.0.min.js:808:71) at cc.Layer.extend.initBackground (public_html/theCrushers.js:19:36) at cc.Layer.extend.init (public_html/theCrushers.js:14:14) at cc.Scene.extend.onEnter (public_html/theCrushers.js:29:19) at (public_html/lib/Cocos2d-html5-v2.0.min.js:2:351) at cc.Director.cc.Class.extend.setNextScene (public_html/lib/Cocos2d-html5-v2.0.min.js:705:463) at cc.Director.cc.Class.extend.drawScene (public_html/lib/Cocos2d-html5-v2.0.min.js:697:396) at cc.DisplayLinkDirector.cc.Director.extend.mainLoop (public_html/lib/Cocos2d-html5-v2.0.min.js:715:353) at a (public_html/lib/Cocos2d-html5-v2.0.min.js:758:433)

The game didn’t work after this. This is my test code when I try to load a map:

`var sceneGame = cc.Layer.extend({
_map:null,
init:function() {
//var layerBg = cc.LayerColor.create(new cc.Color4B(0, 0, 0, 255), 800, 600);
//layerBg.setPosition(new cc.p(0, 0));

    //var player = new Character();
    //player.init();
    //player.initWithTexture(cc.TextureCache.getInstance().addImage("img/cars/cars01.png"), cc.rect(0, 128, 129, 64));
    //player.setPosition(new cc.p(400, 300));

    //layerBg.addChild(player);
    //this.addChild(layerBg);
    this.initBackground();

    return true;
},
initBackground:function() {
    this._map = cc.TMXTiledMap.create("maps/city01.tmx", -1);
    this.addChild(this._map);
}

});

var sceneManager = cc.Scene.extend({
onEnter:function() {
this._super();

    var currScene = new sceneGame();
    currScene.init();
    this.addChild(currScene);
}

});`

What I have did wrong? Anyone have the same problem? How can I solve this?

I’ll appreciate all your answers! Sorry about my bad/weird english, I’m not native!

Best regards,
Alexandre.

you should reload the resource.

jk la wrote:

you should reload the resource.

How?

use this
cc.Loader.shareLoader().preload();

More like this

cc.LoaderScene.preload(resourcelist, function () {
    ...
}, this);