In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: forked from: forked from: 単位球面上の移動

ColorTransformの方がいい気がしてきた

backgroundColor=0x000000
/**
 * Copyright zaltech ( http://wonderfl.net/user/zaltech )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/92PT
 */

// forked from zaltech's forked from: forked from: 単位球面上の移動
// forked from uwi's forked from: 単位球面上の移動
// ColorTransformの方がいい気がしてきた
// forked from 178ep3's 単位球面上の移動
package
{
    import flash.display.Sprite;
    import flash.events.Event;
    // backgroundColor=0x000000
     [SWF(width=465, height=465, frameRate=30, backgroundColor=0xEAEFF2)] 
    public class Sphere extends Sprite
    {
                private const N : int = 200;
    
        public function Sphere()
        {
            var i:int = 0;
            var list:Array = [];
            for(i=0; i<N; i++)
            {
                var d:Dot = addChild(new Dot(i))as Dot;
                list.push(d);
            }
            
            addEventListener(Event.ENTER_FRAME,upup);
            
            function upup(e:Event):void
            {
                for(i=0; i<N; i++)
                {
                    list[i].loop();
                    //list.[i].setRGB(0);
                }
            }
        }
    }
}

    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.Event;

class Dot extends Sprite
{
    private var _x:Number=0;
    private var _y:Number=0;
    private var _z:Number=0;
    
    private var _r:uint = 1;
    
    private var _xyAngle:Number = 0;
    private var _xzAngle:Number = 0;
    private var _xyAdd:Number;
    private var _xzAdd:Number;
    
    private var _rad:uint=100;
    private var _dot:Shape;

        private var _num:int;
        
    public function Dot(setNum:int)
    {
                _num = setNum;
        _xyAngle = setNum*6-90;
        _xzAngle = setNum*5;
        
        this.x = 238;
        this.y = 238;
        
        _xyAdd = 0.7;
        _xzAdd = 1.11;
        
        init();
    }
        
    private function init():void
    {
        /*
        _dot = addChild(new Shape())as Shape;
        //var myColor =0;
        //var nb=0;
        with(_dot.graphics)
        {
           // nb=nb+1;
            //if (nb%2==0) 
               // {
                       myColor=Math.round(Math.random()*0xFFFFFF);
                       //myColor = myColor.toString(16); // convert hex value to a hex string
                        //while (myColor.length < 6) myColor = "0"+myColor; // make sure the hex string has 6 characters
                        //_root.myTextbox.text = "color = #"+myColor; // set it to the textfield text
                        //_dot.myTextbox.text = "color = #"+myColor;
                        //trace(rd);
              //  }
            //EAEFF2
            //beginFill(uint(0xff * _num / 100) * 0x010110);
            beginFill(uint(0xff * _num / 100) * myColor);
            drawCircle(0,0,2);
            endFill();
            */
             var monTexte:TextField = new TextField(); 
            monTexte.text = "Bonjour !"; 
            //addChild ( monTexte ); // affiche : 100 100 
            //_dot = addChild(monTexte)as Shape;
            //trace( monTexte.width, monTexte.height );
        }
    }
    private function init2():void
    {
        
        //var myColor =0;
        //var nb=0;
        
            var monTexte:TextField = new TextField(); 
            monTexte.text = "Bonjour !"; 
            //addChild ( monTexte ); // affiche : 100 100 
            _dot = addChild(monTexte)as Shape;
            trace( monTexte.width, monTexte.height );
        }
    }        
    public function loop():void
    {
        _xyAngle +=_xyAdd;
        _xzAngle +=_xzAdd;
        if(_xyAngle>360)_xyAngle-=360;
        if(_xzAngle>360)_xzAngle-=360;
            
        _x = Math.cos(_xyAngle*Math.PI/180);
        _y = Math.sin(_xyAngle*Math.PI/180);
        _x = _x * Math.cos(_xzAngle*Math.PI/180);
        _z = Math.sqrt(1 - _x * _x - _y * _y);
        if(_xzAngle>180)_z*=-1;
        _dot.x = _x*_rad;
        _dot.y = _y*_rad;

        _dot.scaleX = _dot.scaleY = _z+1.1;
        //var rd=Math.round(Math.random()*0xFFFFFF);
        //var rd=0;
        //this.graphics.beginFill(rd);
        //cCircle = new Color(Dot);
        //cCircle.setRGB(rd);
    }
}