zoukankan      html  css  js  c++  java
  • Flash 随机生成多个显示元件的ActionScript代码

    学习flash的练习,随机生成多个sprite显示元件,纯actionscript3.0代码。
    Sprite显示元件颜色随机,大小随机 

     



    代码如下:

    public function testCreateSprite():void
    {
    for (var i:int = 0;i < 99; i++ )
    {
    var s:Sprite = new Sprite;
    s.name = "hiname_" + i;
    var color:int = Math.floor(Math.random() * 0xFFFFFF); //生成随机颜色
    var size:int = Math.floor(Math.random() * 35); //生成随机大小
    s.graphics.beginFill(color);
    s.graphics.drawCircle(Math.random() * 700 +10, Math.random() * 600 +10, size);
    s.graphics.endFill();
    this.addChild(s);

    s.addEventListener(MouseEvent.CLICK, clickHandler);
    //s.addEventListener(MouseEvent.MOUSE_OVER, overHandler);
    }
    }

    private function clickHandler(event:MouseEvent):void
    {
    trace("You click : " + event.target.name + "_typeof:" + typeof event.target.name );

    this.removeChild(DisplayObject(event.target));

    //var n:int = this.stage.numChildren;
    //for (var i:int = 0; i < n; i++ ) {
    //this.stage.removeChildAt(i);
    //}

    //var myTimer:MyTimer = MyTimer.getInstance();
    //myTimer.registerTimer(event.target.name, 1, 20, movetoRight,event.target.name);
    }


     

  • 相关阅读:
    输入和输出--java的NIO
    Java的NIO
    Java的nio
    输入和输出--java序列化机制
    输入和输出--javase中的路径
    输入和输出--重定向标准输入和输出
    输入和输出--RandomAccessFile类
    输入和输出--IO流
    输入和输出--File类
    无废话XML--DOM4J
  • 原文地址:https://www.cnblogs.com/didi/p/2254523.html
Copyright © 2011-2022 走看看