About

<#TEMPLATE_INCLUDE_NINEPAGE_ABOUTME#>
  • Jan

    5

    回顾 Starling2 —— Starling 的设置过程仍然是异步的

    • 0 Comments
    • Flash Platform
    • 发布:古树悬叶
    • 引用:0
    • 浏览:

    和 Starling旧版一样,2.0的版本设置步骤仍然是异步的,也就是如下步骤产生 Game 类的实例并不是同步的,不能直接调用 Game 类实例中的方法:

    package
    {
        import flash.display.Sprite;
        import starling.core.Starling;

        [SWF(width="640", height="480",
             backgroundColor="#808080",
             frameRate="60")]
        public class Main extends Sprite
        {
            private var _starling:Starling;

            public function Main()
            {
                _starling = new Starling(Game, stage);
                _starling.start();
            }
        }
    }

    但可以侦听 ROOT_CREATED 事件:

    public function Main()
    {
        _starling = new Starling(Game, stage);
        _starling.addEventListener(Event.ROOT_CREATED, onRootCreated);
        _starling.start();
    }

    private function onRootCreated(event:Event, root:Game):void
    {
        root.start(); // 'start' needs to be defined in the 'Game' class
    }
    • Tags:
    • 2017 / 1 / 5
    相关文章:
      Post Comment.

      发表评论