[LayaAir 1.0]照着官方文档写的 Dialog 报错?
var LoadResource = function () {照着官方文档实例, 写了一个显示 Dialog 代码, 怎么显示不出来?而且F12里输出报错:
LoadResource.prototype.init = function () {
this._container = new Sprite();
Laya.stage.addChild(this._container);
Laya.loader.load(["../bin/res/ui/progressBar.png", "../bin/res/ui/progressBar$bar.png"], Handler.create(this, this.onPreloaded));
};
LoadResource.prototype.onPreloaded = function () {
this.initLoadData();
};
LoadResource.prototype.initLoadData = function () {
var res_array = [
{url:"res/ui/dialog.png",type:Laya.Loader.IMAGE},
{url:"res/ui/close.png",type:Laya.Loader.IMAGE}
];
Laya.loader.load(assets, Handler.create(this, onAssetLoaded));
};
LoadResource.prototype.onAssetLoaded = function () {
var dialog = new Dialog();
var bgImg = new Image("res/ui/dialog.png");
dialog.addChild(bgImg);
// bgImg.size(400, 458);
var button = new Button("res/ui/close.png");
button.size(50, 50);
button.name = Dialog.CLOSE;
button.pos(bgImg.width - button.width - 5, 5);
dialog.addChild(button);
dialog.dragArea = "0,0," + bgImg.width + "," + bgImg.height;
dialog.show();
};
}
Laya.class(LoadResource, "LoadResource", null);
Uncaught TypeError: Cannot read property 'visible' of undefined
不知道是什么情况? 求指导。
没有找到相关结果
已邀请:
要回复问题请先登录
0 个回复