Help us understand the problem. What is going on with this article?

Starling Framework使う時のコピペ用ドキュメントクラス

More than 5 years have passed since last update.
starlingTemplate.as
package 
{
    import starling.core.Starling;

    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.geom.Rectangle;

    /**
    * starling つかうときのコピペ用ドキュメントクラス
    */
    public class StarlingSample extends Sprite
    {
        private var _starling : Starling;
        public function StarlingSample()
        {
            if(stage) _initialize(null); 
            else  addEventListener(Event.ADDED_TO_STAGE, _initialize);

        }

        private function _initialize(event : Event) : void
        {
            removeEventListener(Event.ADDED_TO_STAGE, _initialize);
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;

            this.mouseEnabled = false;
            this.mouseChildren = false;
            this.loaderInfo.addEventListener(Event.COMPLETE, loaderInfo_completeHandler);
        }



        private function loaderInfo_completeHandler(event : Event) : void
        {
            Starling.handleLostContext = true;
            Starling.multitouchEnabled = false;

            _starling = new Starling(Main, stage);
            _starling.enableErrorChecking = true;
            _starling.start();

            this.stage.addEventListener(Event.RESIZE, stage_resizeHandler, false, int.MAX_VALUE, true);
            this.stage.addEventListener(Event.DEACTIVATE, stage_deactivateHandler, false, 0, true);
        }

        private function stage_resizeHandler(event : Event) : void
        {
            _starling.stage.stageWidth = stage.stageWidth;
            _starling.stage.stageHeight = stage.stageHeight;

            const viewPort : Rectangle = _starling.viewPort;
            viewPort.width = stage.stageWidth;
            viewPort.height = stage.stageHeight;
            try {
                _starling.viewPort = viewPort;
            }
            catch(error : Error) {
            }
        }

        private function stage_deactivateHandler(event : Event) : void
        {
           _starling.stop();
            stage.addEventListener(Event.ACTIVATE, stage_activateHandler, false, 0, true);
        }

        private function stage_activateHandler(event : Event) : void
        {
            stage.removeEventListener(Event.ACTIVATE, stage_activateHandler);
            _starling.start();
        }
    }
}
itoz
http://itoz.jp/ 最近はnuxt。
http://itoz.jp/
kakusininc
Webサイト構築 から実空間でセンサー系デジタルエンターテイメントまで幅広く制作するデジタル・クリエイティブスタジオ
http://kakus.in/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away