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

flash on 2009-12-13

Get Adobe Flash player
by uwi 13 Dec 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/mHCp
 */

package {
    import flash.display.*;
    import com.bit101.components.*;
    
    public class FlashTest extends Sprite {
        private var _v : Number = 20.0;
        private var _omega : Number;
        private var _bmd : BitmapData;
        
        public function FlashTest() {
            
            _bmd = new BitmapData(465, 465, false, 0x000000);
            addChild(new Bitmap(_bmd));
            
            var hSlider : HUISlider = new HUISlider(this, 10, 10, "", function() : void
            {
                _omega = hSlider.value;
                _bmd.lock();
                _bmd.fillRect(_bmd.rect, 0);
                rec(10, 0, 0, 0);
                _bmd.unlock();
            });
            hSlider.labelPrecision = 3;
            hSlider.maximum = 0.6;
            hSlider.minimum = 0.0;
            hSlider.value = 0.2;
            
            _omega = 0.2;
            _bmd.lock();
            rec(10, 0, 0, 0);
            _bmd.unlock();
        }
        
        private function rec(left : int, x : Number, y : Number, theta : Number) : void
        {
            _bmd.setPixel(200 + x, 465 / 2 - y, 0xffffff);
            if(left == 0){
                return;
            }
            
            for each(var t : Number in [-_omega, 0, _omega]){
                var nt : Number = theta + t;
                rec(left - 1, x + _v * Math.cos(nt), y + _v * Math.sin(nt), nt);
            }
        }
    }
}