2016-06-10 42 views
0

我是新來的使用動作腳本,(如真的很新,我什麼都不知道),但我在學校爲項目製作計算器時遇到麻煩。這可能是非常明顯的事情,但當涉及到這個東西時我很空虛,所以任何人都可以幫忙?AS3右派倫失蹤錯誤?

這是代碼:

output=0; 
function addInput(num) { 
    if(accept=="calcText") { 
    if(output=="0") { 
     output=num; 
    } else { 
     output=output+num; 
    } 
    } else if(accept=="new") { 
    output=num; 
    accept="calcText"; 
    } 
} 

function type(type) { 
    holder = Number(output); 
    accept = "new"; 
    calcType = type; 
} 
function calculate() { 
    if(calcType=="+") { 
    doPlus("+"); 
    } else if(calcType=="-") { 
    doMinus("-"); 
    } else if(calcType=="*") { 
    doPlus(); 
    } else if(calctype=="-") { 
    doMinus(); 
    } else if(calcType=="*") { 
    doTimes(); 
    } else if(calcType=="/") { 
    doDivide(); 
    } 
} 
accept="calcText"; 

on(release, keyPress"+") { 
    function doPlus() { 
    output = holder+Number (output); 
    } 
    type("+"); 
} 


on(release, keyPress"-") { 
    function doMinus() { 
    output = holder-Number (output); 
    } 
    type("-"); 
} 
on(release,keyPress"/") { 
    function doDivide() { 
    output = holder/Number (output); 
    } 
    type("/"); 
} 
on(release,keyPress"*") { 
    function doTimes() { 
    output = holder*Number (output); 
    } 
    type("*"); 
} 
stop(); 

而這種誤差被顯示出來:

Scene 1, Layer 'Button', Frame 171, Line 63, Column 21 1084: Syntax error: expecting rightparen before "+".

Scene 1, Layer 'Button', Frame 171, Line 73, Column 21 1084: Syntax error: expecting rightparen before "-".

Scene 1, Layer 'Button', Frame 171, Line 82, Column 20 1084: Syntax error: expecting rightparen before "/".

Scene 1, Layer 'Button', Frame 171, Line 91, Column 20 1084: Syntax error: expecting rightparen before "*".

如何解決此錯誤?

回答

0

你發佈的內容不是ActionScript。我不確定它是什麼。 這是我認爲你想要的AS版本。

someButton.addEventListener(MouseEvent.CLICK, buttonClicked); 
function buttonClicked(e:MouseEvent) { 
    trace("You clicked the button"); 
} 

您是否可以發佈您的完整源代碼? 你正在使用放置在舞臺上的按鈕/對象嗎?