访问 AS3 中的舞台

发布于 2024-09-27 05:02:01 字数 530 浏览 0 评论 0原文

我试图让投影仪文件在启动时全屏运行,而不需要单击任何内容。我的主类继承自 MovieClip,因此据我所知,我可以访问舞台...是的,对:)

package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.display.StageDisplayState;
    import flash.display.Stage;
    import flash.ui.Mouse;


    public class PhoneDemo extends MovieClip
    {
        Stage.displayState=StageDisplayState.FULL_SCREEN;
        //declare variables
        public var scoreArray:Array = [null];

这根本不起作用,我无法访问舞台,我收到错误 1120。当然我以前也曾登上过舞台,但我真的很困惑。

I'm trying to get a projector file to run full screen when it starts, without needing to click anything. My main class inherits from MovieClip, so as far as I can tell I get access to stage... yeah right :)

package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.display.StageDisplayState;
    import flash.display.Stage;
    import flash.ui.Mouse;


    public class PhoneDemo extends MovieClip
    {
        Stage.displayState=StageDisplayState.FULL_SCREEN;
        //declare variables
        public var scoreArray:Array = [null];

This simply doesn't work, I can't gain access to stage, I get error 1120. I'm sure I've gained access to the stage before, I'm really confused.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼中杀气 2024-10-04 05:02:01

stage 是 DisplayObject 的一个属性; Stage 是类。

尝试以小写形式访问它。另外,如果您在构造函数中访问阶段,那么它还没有被分配。

stage is a property of DisplayObject; Stage is the class.

Try accessing it in lowercase instead. Also, if you access the stage in the constructor it won't have been assigned yet.

淡墨 2024-10-04 05:02:01
public class PhoneDemo extends MovieClip{
   addEventListener(Event.ADDED_TO_STAGE, addedToStage);
   // you cannot access the stage here, because the stage relation has not been established
}

internal function addedToStage(e:Event){
    removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
    // you  can access the stage here
}
public class PhoneDemo extends MovieClip{
   addEventListener(Event.ADDED_TO_STAGE, addedToStage);
   // you cannot access the stage here, because the stage relation has not been established
}

internal function addedToStage(e:Event){
    removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
    // you  can access the stage here
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文