level 1
大行疯者
楼主
最近买了本书准备自学游戏制作
坑爹的按书上的教程做了个范例
是一个猫通过按钮在三页画面切换的
但每次都报错说不能为空at Main()
卅家肯定编码和书上打的一样
求大神帮忙看看到底哪有问题啊啊啊啊
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip
{
var startPage:StartPage;
var hillPage:HillPage;
var pondPage:PondPage;
public function Main()
{
startPage = new StartPage();
hillPage = new HillPage();
pondPage = new PondPage();
addChild(startPage);
//Add event listeners
startPage.hillButton.addEventListener(MouseEvent.CLICK, onHillButtonClick);
startPage.pondButton.addEventListener(MouseEvent.CLICK, onPondButtonClick);
hillPage.backToStartButton.addEventListener(MouseEvent.CLICK,onBackButtonClick_Hill);
pondPage.backToStartButton.addEventListener(MouseEvent.CLICK,onBackButtonClick_Pond);
}
//Event handlers
function onHillButtonClick(event:MouseEvent):void
{
addChild(hillPage);
removeChild(startPage);
}
function onPondButtonClick(event:MouseEvent):void
{
addChild(pondPage);
removeChild(startPage);
}
function onBackButtonClick_Hill(event:MouseEvent):void
{
addChild(startPage);
removeChild(hillPage);
}
function onBackButtonClick_Pond(event:MouseEvent):void
{
addChild(startPage);
removeChild(pondPage);
}
}
}
2011年10月23日 02点10分
1
坑爹的按书上的教程做了个范例
是一个猫通过按钮在三页画面切换的
但每次都报错说不能为空at Main()
卅家肯定编码和书上打的一样
求大神帮忙看看到底哪有问题啊啊啊啊
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip
{
var startPage:StartPage;
var hillPage:HillPage;
var pondPage:PondPage;
public function Main()
{
startPage = new StartPage();
hillPage = new HillPage();
pondPage = new PondPage();
addChild(startPage);
//Add event listeners
startPage.hillButton.addEventListener(MouseEvent.CLICK, onHillButtonClick);
startPage.pondButton.addEventListener(MouseEvent.CLICK, onPondButtonClick);
hillPage.backToStartButton.addEventListener(MouseEvent.CLICK,onBackButtonClick_Hill);
pondPage.backToStartButton.addEventListener(MouseEvent.CLICK,onBackButtonClick_Pond);
}
//Event handlers
function onHillButtonClick(event:MouseEvent):void
{
addChild(hillPage);
removeChild(startPage);
}
function onPondButtonClick(event:MouseEvent):void
{
addChild(pondPage);
removeChild(startPage);
}
function onBackButtonClick_Hill(event:MouseEvent):void
{
addChild(startPage);
removeChild(hillPage);
}
function onBackButtonClick_Pond(event:MouseEvent):void
{
addChild(startPage);
removeChild(pondPage);
}
}
}