• Draw类、Shape类、Sprite类 的 相关使用


                                                                 绘画奥运五环

    package {

     import flash.display.MovieClip;

     import flash.display.Sprite;

     public class DrawMain extends MovieClip

     {        

      private var sp:Sprite;

      private var sp1:Sprite;

      private var sp2:Sprite;

      private var sp3:Sprite;  

     private var sp4:Sprite;

     private var txt:TXT;      

    public function DrawMain()   

    {    

        sp = new Sprite();

       sp.graphics.lineStyle(1,0x00ffff,0.5,true);

       sp.graphics.drawCircle(153,188,50);

       stage.addChild(sp);

       sp1 = new Sprite();

       sp1.graphics.lineStyle(1,0xff00ff,0.5,true);

       sp1.graphics.drawCircle(235,193,50);

       stage.addChild(sp1);

       sp2 = new Sprite();

       sp2.graphics.lineStyle(1,0x123456,0.5,true);

       sp2.graphics.drawCircle(273,126,50);

       stage.addChild(sp2);

       sp3 = new Sprite();

       sp3.graphics.lineStyle(1,0x456789,0.5,true);

       sp3.graphics.drawCircle(196,125,50);

       stage.addChild(sp3);

       sp4 = new Sprite();

       sp4.graphics.lineStyle(1,0x789000,0.5,true);

       sp4.graphics.drawCircle(126,125,50);

       stage.addChild(sp4);

       txt = new TXT;

       txt.x = 421;

       txt.y = 204;

       stage.addChild(txt);

      }

     }

    }

                                                                          方块旋转效果

    package
    {
     import flash.display.GradientType; 
     import flash.display.BlendMode; 
     import flash.display.Shape;
     import flash.display.Sprite;
     import flash.events.Event;  
     
     [SWF(width = 550, height =400, frameRate = 50)]
     
     public class Main extends Sprite
     {
      private var scont : Sprite = new Sprite();
     
      public function Main()
      {
       scont.x = 275;
       scont.y = 200;
       addChild(scont);
       scont.rotationY = 90;
       for(var i : int = 0 ;i < 48; i++)
       {
        var s : Shape = new Shape();
        s.graphics.beginFill((0xffffff*Math.random ()),.6);
        //s.graphics.drawCircle(Math.floor(i / 3) * 15, i, 25);
        s.graphics.drawRect(Math.floor(i / 3) * 15 - 25, i - 25, 50,50);
        s.graphics.endFill();
        scont.addChild(s);
       }
     
     
       addEventListener(Event.ENTER_FRAME, onEnterFrame);
      }
     
      private function onEnterFrame(event : Event) : void
      {
       for(var i : int = 0 ;i < 48;i++)
       {
        var s : Shape = scont.getChildAt(i) as Shape;
        s.rotation += (i / 6) * .7;
       }
       scont.rotation+=.7;
       scont.rotationY += .3;
      }
     }
    }

                                                        任意画折线

    package

      {

     import flash.display.*;

     import flash.events.*;

     //import flash.events.MouseEvent;

         public class ZheXianMain extends MovieClip

     {

            private var sp:Sprite;

         public function ZheXianMain()

      {

       init();

      }

      private function init()

      {

         stage.addEventListener(MouseEvent.MOUSE_DOWN,OnHuaXianHandler);

      }

      private function OnHuaXianHandler(e:MouseEvent):void

      {

                  sp = new Sprite();

                 addChild(sp);

                 sp.x=mouseX;

                 sp.y=mouseY;

                 stage.addEventListener(Event.ENTER_FRAME,OnQiDianHandler);

      }

      private function OnQiDianHandler(e:Event):void

      {

                 sp.graphics.clear();

                sp.graphics.lineStyle(1);

                sp.graphics.moveTo(0, 0);

                sp.graphics.lineTo(mouseX - sp.x, mouseY - sp.y);

                stage.addEventListener(MouseEvent.MOUSE_UP,OnJieSuHandler);

      }

      private function OnJieSuHandler(e:MouseEvent):void

      {

          stage.removeEventListener(MouseEvent.MOUSE_DOWN,OnQiDianHandler);

          stage.addEventListener(MouseEvent.CLICK,OnClickHandler);

      }

      private function OnClickHandler(e:MouseEvent):void

      {

       stage.removeEventListener(Event.ENTER_FRAME,OnQiDianHandler);

      }

     }

    }

                                                                              任意画直线                                    

    package 

    {

     import flash.display.*;

     import flash.events.*;

     //import flash.events.MouseEvent;

     public class XianMain extends MovieClip

     {

            private var sp:Sprite;

         public function XianMain()

      {

       stage.addEventListener(MouseEvent.MOUSE_DOWN,OnHuaXianHandler);

      }

      private function OnHuaXianHandler(e:MouseEvent):void  

     {

                 sp = new Sprite();

                 addChild(sp);

                 sp.x=mouseX;

                 sp.y=mouseY;

                 stage.addEventListener(Event.ENTER_FRAME,OnQiDianHandler);

      }

      private function OnQiDianHandler(e:Event):void

      {

                sp.graphics.clear();

                sp.graphics.lineStyle(1);

                sp.graphics.moveTo(0, 0);

                sp.graphics.lineTo(mouseX - sp.x, mouseY - sp.y);

                stage.addEventListener(MouseEvent.MOUSE_UP,OnJieSuHandler);

      }

      private function OnJieSuHandler(e:MouseEvent):void

      {

          stage.removeEventListener(Event.ENTER_FRAME,OnQiDianHandler);

      }

     }

    }

                                                                                               画圆

    package  {
     
     import flash.display.MovieClip;
     import flash.display.Sprite;
     import flash.events.MouseEvent;
     import flash.events.Event;
     
     
     public class huayuan extends MovieClip {
     
     private var sp:Sprite;
     private var a:Number;
     private var b:Number;
      
      
      public function huayuan() {
       stage.addEventListener(MouseEvent.MOUSE_DOWN,ondown)
       stage.addEventListener(MouseEvent.MOUSE_UP,onup)
      }
      
      private function ondown(e:MouseEvent):void
      {
       sp = new Sprite();
       a = mouseX;
       b = mouseY;
       stage.addChild(sp);
       stage.addEventListener(Event.ENTER_FRAME,onframe)
      }
      private function onframe(e:Event):void
      {
       sp.graphics.clear();
       sp.graphics.lineStyle(2,0x00ff00)
       sp.graphics.drawEllipse(a,b,mouseX-a,mouseY-b)
       stage.addChild(sp)
      }
      
      private function onup(e:MouseEvent):void
      {
       stage.removeEventListener(Event.ENTER_FRAME,onframe)
      }
     }
     
    }

  • 相关阅读:
    在spring boot中三分钟上手apache顶级分布式链路追踪系统skywalking
    Spring Boot Admin 2.1.0
    Spring Boot Admin 详解(Spring Boot 2.0,基于 Eureka 的实现)
    Spring Cloud Sleuth + Zipkin 链路监控
    guava布隆过滤器
    红包算法
    java国际化之时区问题处理
    SpringCloud2.0 Hystrix Feign 基于Feign实现断路器
    SpringBoot 自定义线程池,多线程
    基于Redisson+SpringBoot的Redission分布式锁
  • 原文地址:https://www.cnblogs.com/klh5211314/p/2763341.html
Copyright © 2020-2023  润新知