测试简书,测试添加代码

下面添加一段简单的AS3.0的代码片段

用于测试验证简书的Markdown功能

```
package

{

    import flash.display.Sprite;

    import flash.events.TouchEvent;

    import flash.text.AntiAliasType;

    import flash.text.TextField;

    import flash.text.TextFormat;

    import flash.ui.Multitouch;

    import flash.ui.MultitouchInputMode;

    [SWF(width=320, height=460, frameRate=24, backgroundColor=0xEB7F00)]

    public class TouchExample2 extends Sprite

    {

        private var dots:Object;

        private var labels:Object;

        private var labelFormat:TextFormat;

        private var dotCount:uint;

        private var dotsLeft:TextField;

        private static const LABEL_SPACING:uint = 15;


        public function TouchExample2()

        {

            super();

            this.labelFormat = new TextFormat();

            labelFormat.color = 0xACF0F2;

            labelFormat.font = "Helvetica";

            labelFormat.size = 11;


            this.dotCount = 0;

            this.dotsLeft = new TextField();

            this.dotsLeft.width = 300;

            this.dotsLeft.defaultTextFormat = this.labelFormat;

            this.dotsLeft.x = 3;

            this.dotsLeft.y = 0;

            this.stage.addChild(this.dotsLeft);

            this.updateDotsLeft();

            this.dots = new Object();

            this.labels = new Object();

            Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

            this.stage.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);

            this.stage.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove);

            this.stage.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);

        }

        private function onTouchBegin(e:TouchEvent):void

        {

            if (this.dotCount == Multitouch.maxTouchPoints) return;

            var dot:Sprite = this.getCircle();

            dot.x = e.stageX;

            dot.y = e.stageY;

            this.stage.addChild(dot);

            dot.startTouchDrag(e.touchPointID, true);

            this.dots[e.touchPointID] = dot;


            ++this.dotCount;

            var label:TextField = this.getLabel(e.stageX + ", " + e.stageY);

            label.x = 3;

            label.y = this.dotCount * LABEL_SPACING;

            this.stage.addChild(label);

            this.labels[e.touchPointID] = label;

            this.updateDotsLeft();

        }


        private function onTouchMove(e:TouchEvent):void

        {

            var label:TextField = this.labels[e.touchPointID];

            label.text = (e.stageX + ", " + e.stageY);

        }


        private function onTouchEnd(e:TouchEvent):void

        {

            var dot:Sprite = this.dots[e.touchPointID];

            var label:TextField = this.labels[e.touchPointID];


            this.stage.removeChild(dot);

            this.stage.removeChild(label);


            delete this.dots[e.touchPointID];

            delete this.labels[e.touchPointID];


            --this.dotCount;

            this.updateDotsLeft();

        }


        private function getCircle(circumference:uint = 40):Sprite

        {

            var circle:Sprite = new Sprite();

            circle.graphics.beginFill(0x1695A3);

            circle.graphics.drawCircle(0, 0, circumference);

            return circle;

        }

        private function getLabel(initialText:String):TextField

        {

            var label:TextField = new TextField();

            label.defaultTextFormat = this.labelFormat;

            label.selectable = false;

            label.antiAliasType = AntiAliasType.ADVANCED;

            label.text = initialText;

            return label;

        }


        private function updateDotsLeft():void

        {

            this.dotsLeft.text = "Touches Remaining: " + (Multitouch.maxTouchPoints - this.dotCount);

        }

    }

}

```

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容