我正在使用 Flash Professional CS6/AS3 制作一个简单的游戏。我想要一个后退按钮,当单击该按钮时,播放器将返回到介绍屏幕。其他一切正常,但按钮不会显示在屏幕上,当我将它拖到屏幕上并单击它时它也不会起作用。back_Btn 类为空,符号不包含时间线代码。
没有错误消息。我想重申,其他一切都运行良好。
这是文档类:
package
{
import com.greensock.TweenLite;
import com.greensock.*;
import com.greensock.easing.*;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Stage;
import flash.display.SimpleButton;
public class Main extends MovieClip
{
var back1:back_Btn;
var intro:introScreen;
var game:levelOne;
var stageRef:Stage;
//
var timer:Number = 0;
var holder:int = 0;
var boolean:Boolean = false;
var speed:int;
//
public function Main()
{
init();
}
function init():void
{
stageRef = stage;
back1 = new back_Btn();
stageRef.addChild(back1);
//
game = new levelOne();
//
intro = new introScreen();
stageRef.addChild(intro);
//
back1.x = 425;
back1.y = 0;
intro.x = 0;
intro.y = 0;
intro.lampBtn.addEventListener(MouseEvent.CLICK,startGame);
addEventListener(Event.ENTER_FRAME,startApp);
back1.addEventListener(MouseEvent.CLICK,exitGame);
speed = 0;
function startApp(evt:Event):void
{
intro.x += speed;
if ((boolean == true))
{
speed = 5;
boolean = false;
}
}
}
function startGame(evt:Event):void
{
game = new levelOne ;
stageRef.addChild(game);
game.x = 0;
game.y = 0;
boolean = true;
}
function exitGame(evt:Event):void
{
trace("back button clicked");
removeChild(game);
addChild(intro);
intro.visible = true;
}
}
}
不拖到舞台上时,按钮不会出现。拖动时,单击时不会触发跟踪语句,并且没有任何反应。很奇怪。