如何修复此重复的函数定义错误?

时间:2014-03-01 20:20:02

标签: actionscript-3 encoding flash-cs6

我是Flash CS6动作脚本3的新手。我必须分配一个必须有鼠标,键盘,输入框架和时间事件的场景。每次我测试电影时,我都会继续收到一条错误,说“关于'输入帧事件'和'定时器事件'功能'的'重复功能定义'。我试图重命名函数,但它没有用。还有另一个解决方案吗?还有,请你举一些例子吗?谢谢!

QuestionMC.addEventListener(MouseEvent.CLICK, onClick);
QuestionMC.addEventListener(MouseEvent.ROLL_OVER, questionOver);
QuestionMC.addEventListener(MouseEvent.ROLL_OUT, questionOut);

function questionOver(event:MouseEvent):void
{
    event.target.alpha = .5;
}

function questionOut(event:MouseEvent):void
{
    event.target.alpha = 1;
}

function onClick(event:MouseEvent):void
{
    //trace("click!!!");
    event.target.y -= 15;
    event.target.rotation += 45;
}

QuestionMC.buttonMode = true;

stage.addEventListener(KeyboardEvent.KEY_DOWN, jump);
stage.addEventListener(KeyboardEvent.KEY_UP, land);

function jump (event:KeyboardEvent): void
{
    trace(event.keyCode);
    YoshiMC.y -= 50
    stage.removeEventListener(KeyboardEvent.KEY_DOWN, jump);
    stage.addEventListener(Event.ENTER_FRAME, flip);
}
function land (event:KeyboardEvent): void
{
    YoshiMC.y += 50
    stage.addEventListener(KeyboardEvent.KEY_DOWN, jump);
    stage.removeEventListener(Event.ENTER_FRAME, flip);
}
function flip(event:Event):void
{
    YoshiMC.rotation += 45;
    YoshiMC.x += 20;
}
var jumpTimer:Timer = new Timer(5000,1);
jumpTimer.addEventListener(TimeEvent.TIMER, jump);
function jump (event:TimerEvent):void
{
    planteaterMC.play();
}
jumpTimer.start();

var link:URLRequest = new URLRequest("");

buttongoeshere.addEventListener(MouseEvent.CLICK, clickHere);

function clickHere(event:MouseEvent):void
{
    navigateToURL(link);
}
buttongoeshere.buttonMode = true;

1 个答案:

答案 0 :(得分:0)

您的jump函数已声明两次,此处为:

function jump (event:KeyboardEvent): void

在这里:

function jump (event:TimerEvent):void

您只需要重命名其中一个