添加增长和缩小按钮代码后,我的代码出现问题。它在告诉我
“C:\Users\Dan\Desktop\Flash\Interactive Story Book\Main.as,第 28 行 1120:访问未定义属性 onShrinkButtonClick。”
“C:\Users\Dan\Desktop\Flash\Interactive Story Book\Main.as,第 29 行 1120:访问未定义属性 onGrowButtonClick。
实例名称是正确的,与我的 AsLinkage 或对象名称不同。
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip
{
var startPage:StartPage;
var hillPage:HillPage;
var lakePage:LakePage;
public function Main()
{
startPage = new StartPage();
hillPage = new HillPage();
lakePage = new LakePage();
addChild(hillPage);
//Add event listeners
startPage.buttonHill.addEventListener(MouseEvent.CLICK, onHillButtonClick);
startPage.buttonLake.addEventListener(MouseEvent.CLICK, onLakeButtonClick);
hillPage.btsButton.addEventListener(MouseEvent.CLICK, onStartButtonClick_hill);
lakePage.btsButton.addEventListener(MouseEvent.CLICK, onStartButtonClick_lake);
hillPage.upButton.addEventListener(MouseEvent.CLICK, onUpButtonClick);
hillPage.downButton.addEventListener(MouseEvent.CLICK, onDownButtonClick);
hillPage.shrinkButton.addEventListener(MouseEvent.CLICK, onShrinkButtonClick);
hillPage.growButton.addEventListener(MouseEvent.CLICK, onGrowButtonClick);
}
//Event handlers
function onHillButtonClick(event:MouseEvent):void
{
addChild(hillPage);
removeChild(startPage);
}
function onLakeButtonClick(event:MouseEvent):void
{
addChild(lakePage);
removeChild(startPage);
}
function onStartButtonClick_hill(event:MouseEvent):void
{
addChild(startPage);
removeChild(hillPage);
}
function onStartButtonClick_lake(event:MouseEvent):void
{
addChild(startPage);
removeChild(lakePage);
}
function onUpButtonClick(event:MouseEvent):void
{
hillPage.cat.y -=15
if(hillPage.cat.y < 90)
{
hillPage.cat.y =90
}
}
function onDownButtonClick(event:MouseEvent):void
{
hillPage.cat.y +=15
if(hillPage.cat.y >190)
{
hillPage.cat.y =190
}
function onGrowButtonClick(event:MouseEvent):void
{
hillPage.cat.scaleX +=0.1;
hillPage.cat.scaleY +=0.1;
}
function onShrinkButtonClick(event:MouseEvent):void
{
hillPage.cat.scaleX -=0.1;
hillPage.cat.scaleY -=0.1;
}
}
}
}