【发布时间】:2014-09-02 16:32:04
【问题描述】:
另一个可能很愚蠢的问题。 我遵循了一个教程(Richard Parnaby-King 的爆破游戏)。
我遇到了这个我似乎无法修复的恼人错误。
main.as(称为 test1):
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.utils.Timer;
[SWF(width='800',height='600',backgroundColor='#FFFFFF',frameRate='25')]
public class Test1 extends MovieClip
{
var icon:FacebookIcon = new FacebookIcon();
var background:BG = new BG();
private var timer:Timer = new Timer(5000,-1);
private var bubbles:Array = [];
private var score:int;
private var textBox:TextField = new TextField;
private var textFormat:TextFormat = new TextFormat(null, 30);
public function Test1(); void
{
if(stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
//add start button
icon.addChild(new StartButton());
icon.addEventListener(MouseEvent.CLICK, startGame);
icon.buttonMode = true;
icon.x = (stage.stageWidth / 2) - (icon.width / 2);
icon.y = (stage.stageHeight / 2) - (icon.height / 2);
addChild(icon);
textBox.defaultTextFormat = textFormat;
private function startGame(e:MouseEvent):void {
icon.removeEventListener(MouseEvent.CLICK, startGame);
removeChild(icon);
removeChild(background);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, createBubble);
timer.start();
createBubble();
score = 0;
}
我得到了错误 1084: 语法错误:在 if 之前需要标识符
和
-1084:语法错误:在右括号之前需要冒号
就在哪里
if(stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
我做错了什么?尝试了一切。 非常感谢
【问题讨论】:
-
好吧,你的类、包和 init 方法中缺少右大括号 - 这只是复制和粘贴错误吗?
标签: actionscript-3 flash actionscript flash-builder