我想向特定的js類聲明屬性和函數。但是,當我嘗試調用一個函數(即使宣佈之後調用)的內部函數,它拋出一個異常JavaScript類函數內部調用函數?
遺漏的類型錯誤:對象的翻譯:有沒有方法「addButtonEventListeners
我的代碼所示:SplashScene.js
var anim1, background;
var SplashScene;
function SplashScreen(SceneContainer)
{
this.name = "SplashScreen";
this.loadScreen = function()
{
background = new createjs.Shape();
background.graphics.beginBitmapFill(loader.getResult("gameLoopSplash")).drawRect(0,0,w,h);
SplashScene = new createjs.Container();
anim1 = new createjs.Sprite(buttonData, "playIdle");
anim1.framerate = 30;
anim1.x = 260;
anim1.y = 22;
SplashScene.alpha = 0;
SplashScene.addChild(background);
SplashScene.addChild(anim1);
}
this.addButtonEventListeners = function()
{
console.log("addButtonEventListeners SplashScreen");
}
this.menuIn = function()
{
console.log("menuIn SplashScreen");
stage.addChild(SplashScene);
var tween = createjs.Tween.get(SplashScene).to({y : 0, x : 0, alpha : 1}, 5000).call(this.menuInCompleted);
var splashTimer = window.setTimeout(function(){menuOut("MainScreen", false)},15000);
}
this.menuInCompleted = function()
{
console.log("menuInCompleted SplashScreen");
this.addButtonEventListeners();
}
}
有人可以告訴我我該怎麼做?
菜單吐溫是工作,但菜單不出來。我做了你所說的。但它仍然不起作用。 – starrystar