【问题标题】:Access the Stage in AS3访问 AS3 中的舞台
【发布时间】:2010-10-10 18:07:15
【问题描述】:

我正在尝试让投影仪文件在启动时全屏运行,而无需单击任何内容。我的主类继承自 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。我确定我之前已经获得了阶段的访问权限,我真的很困惑。

【问题讨论】:

    标签: flash actionscript-3 stage


    【解决方案1】:

    stage 是 DisplayObject 的一个属性; Stage 是班级。

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

    【讨论】:

      【解决方案2】:
      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
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-02-02
        • 1970-01-01
        • 2023-03-28
        • 1970-01-01
        • 1970-01-01
        • 2014-07-12
        • 1970-01-01
        • 2010-10-19
        相关资源
        最近更新 更多