【发布时间】:2014-07-03 12:54:12
【问题描述】:
我正在尝试制作菜单,但我的影片剪辑没有出现在舞台上。我用跟踪对其进行了测试,当 'addChild(currentClip) 被执行时它确实开始运行。
它是面向对象的编程,所以我添加了我的整个课程。 对不起cmets,否则我会迷路:)
package
{
import flash.display.MovieClip;
import flash.events.EventDispatcher;
import flash.events.MouseEvent;
import flash.events.Event;
public class IntroClip extends MovieClip
{
var currentClip:MovieClip;
public static const MY_FINISHED_INTRO_CLIP_EVENT:String = "my_finished_intro_clip_event";
// constructor code
public function IntroClip()
{
startButton.addEventListener(MouseEvent.CLICK, openMainGame);
howToButton.addEventListener(MouseEvent.CLICK, openHowTo);
hiscoreButton.addEventListener(MouseEvent.CLICK, openHiscore);
}
//Open het spel
public function openMainGame (event:MouseEvent):void
{
//Bij klikken IntroClip verwijderen en MainGame toevoegen
dispatchEvent(new Event(MY_FINISHED_INTRO_CLIP_EVENT));
currentClip = new MainClip();
trace('addChild')
addChild(currentClip);
currentClip.x=160;
currentClip.y=160;
}
//Open de opties
public function openHowTo (event:MouseEvent):void
{
//Bij klikken IntroClip verwijderen en Options toevoegen
dispatchEvent(new Event(MY_FINISHED_INTRO_CLIP_EVENT));
}
//Open de hiscores
public function openHiscore (event:MouseEvent):void
{
//Bij klikken IntroClip verwijderen en Hiscores toevoegen
dispatchEvent(new Event(MY_FINISHED_INTRO_CLIP_EVENT));
}
}
}
【问题讨论】:
-
应该可以。你是从 Flash 导出的吗?或者它是一个单独的类,比如公共类 MainClip 扩展了 MovieClip?也许你没有添加任何图形?如果跟踪有效,那么它可能已添加到阶段。您可以通过运行 this.getChildIndex(currentClip) 来检查它。如果没有抛出异常,则添加。
-
这是一个单独的类,我会更新我的代码,以便您可以看到我导入的内容。它正在运行,只是它没有出现在舞台上。
-
好的,你能发布 MainClip() 代码还是太大了?
-
MainClip 代码目前为空。
-
这就是你看不到它的原因——没有什么可显示的。如果您创建一个新的 MainClip() 并执行 this.graphics.beginFill(0xff0000);this.graphics.drawRect(0,0,100,100); this.graphics.endFill() 你会在舞台上看到。
标签: actionscript-3 oop