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

copyChannelで模様など

Get Adobe Flash player
by uwi 30 Nov 2009
    Embed
/**
 * Copyright uwi ( http://wonderfl.net/user/uwi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mKFu
 */

package {
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.utils.getTimer;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.geom.Rectangle;
    import flash.events.Event;
    import flash.geom.Point;
    
    [SWF(frameRate=60)]
    public class Test extends Sprite {
        private var _tf : TextField;
        private var _bmd : BitmapData;
  
        public function Test() {
            _tf = new TextField();
            _tf.width = 465;
            _tf.height = 465;
            addChild(_tf);
            
            _bmd = new BitmapData(465, 465, false);
            addChild(new Bitmap(_bmd));
            
            _bmd.lock();
            for(var x : int = 0;x < 465;x++){
                var c : uint = uint(256 * x / 465) * 0x10101;
                _bmd.fillRect(new Rectangle(x, 0, 1, 465), c);
            }
            _bmd.unlock();
            
            var r : Number = 100;
            var theta : Number = 0;
            
            var step : int = 0;
            addEventListener(Event.ENTER_FRAME, function(e : Event) : void {
                    var srcX : Number = 465 / 2 + r * Math.cos(theta);
                    var srcY : Number = 465 / 2 + r * Math.sin(theta);
                    var dstX : Number = 465 / 2 - r * Math.cos(theta);
                    var dstY : Number = 465 / 2 - r * Math.sin(theta);
                    
                    var ind : int = step % 3;
                    var srcC : uint = [1, 2, 4][ind];
                    var dstC : uint = [1, 2, 4][ind];
                    _bmd.copyChannel(_bmd, new Rectangle(srcX - r, srcY - r, 2 * r, 2 * r), new Point(dstX - r, dstY - r), srcC, dstC);
                    theta += 0.005;
                    step++;
                    /*
                    if(++step == 10000){
                        removeEventListener(Event.ENTER_FRAME, arguments.callee);
                    }
                    */
                });
        }

        private function tr(...o : Array) : void
        {
            _tf.appendText(o + "\n");
        }
    }
}