Array not defined issue

Hi, I’m upgrading a game from cocos creator 1.9 to 2.3 and i have a problem.
the browser says that an array is undefined, this is the code that gives me the problem

this.levelsOrder = [];

        this.turnArray = [];

        this.turnArray = this.node.parent.parent.parent.getChildByName("frame_title").getComponent("script_prepareLevels").getTurns();

        this.levelsOrder = this.node.parent.parent.parent.getChildByName("frame_title").getComponent("script_prepareLevels").getLevels();

        this.level = this.node.getChildByName("Label").getComponent(cc.Label).string;

        this.selected = false;

        if(this.levelsOrder[this.level-1] == "normal"){

            this.icon = "icon_virus_levels";

        }else if(this.levelsOrder[this.level-1] == "IA"){

            this.icon = "icon_virus_versus_levels";

        }else if(this.levelsOrder[this.level-1] == "flag"){

            this.icon =  "icon_collect_flag_levels";

        }else if(this.levelsOrder[this.level-1] == "flagVS"){

            this.icon =  "icon_collect_flag_versus_levels";

        }


image

Check the error prompted in the editor. getLevels() should not return undefined.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

I checked getLevels(), and the problem was there, thank you.