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: flash on 2009-4-6 (beaver version)

// forked from makc3d's forked from: flash on 2009-4-6
// forked from no48's flash on 2009-4-6
package {
    import flash.display.*;
    import flash.text.*;
    import flash.events.*;
    import flash.filters.*;
    import flash.geom.*;
    import flash.utils.*;
    public class FlashTest extends MovieClip {
        private var t : Timer;
	private var bmd : BitmapData = new BitmapData (465, 465);
	private var bmp : Bitmap;

        private var beaver:Array = "Beavers are two primarily nocturnal, semi-aquatic species of rodent, one native to North America and one to Eurasia. They are known for building dams, canals, and lodges (homes). They are the second-largest rodent in the world (after the capybara). Their colonies create one or more dams to provide still, deep water to protect against predators, and to float food and building material. The North American beaver population was once more than 60 million, but as of 1988 was 6-12 million. This population decline is due to extensive hunting for fur, for glands used as medicine and perfume, and because their harvesting of trees and flooding of waterways may interfere with other land uses. Beavers are known for their natural trait of building dams in rivers and streams, and building their homes (known as lodges) in the resulting pond. Beavers also build canals to float build materials that are difficult to haul over land. They use powerful front teeth to cut trees and plants that they use for building and for food. In the absence of an existing pond a Beaver has to construct a dam before building his lodge. First they place vertical poles and then fill between the vertical poles with a crisscross of horizontally placed branches. They fill in the gaps between the branches with a combination of weeds and mud until the dam holds back sufficient water to surround the lodge. They are known for their danger signal: when startled or frightened, a swimming beaver will rapidly dive while forcefully slapping the water with its broad tail. This creates a loud slap, audible over great distances above and below water. This noise serves as a warning to beavers in the area. Once a beaver has made this danger signal, nearby beavers dive and may not reemerge for some time. Beavers are slow on land, but good swimmers that can stay under water for as long as 15 minutes. (Wilson, 1971) Rarely does a frightened beaver attack a human. Beavers do not hibernate, but store sticks and logs in a pile in their pond. Some of the pile is generally above water which accumulates snow in the winter. The insullation of the snow often keeps the water from freezing in and around their food pile which provides a location where beavers can breath when outside their lodge. Fossil remains of beavers are found in the peat and other superficial deposits of Britain and the continent of Europe; while in the Pleistocene formations of Britain and Siberia, occur remains of a giant extinct beaver, Trogontherium cuvieri, representing a genus by itself. Beavers have webbed hind-feet, and a broad, scaly tail. They have poor eyesight, but keen senses of hearing, smell, and touch. Beaver swimmingBeavers continue to grow throughout life. Adult specimens weighing over 25 kg (55 lb) are not uncommon. Females are as large as or larger than males of the same age, which is uncommon among mammals.".split (" ");
        private var beaverIndex:int = 0;

        private var bf:BlurFilter = new BlurFilter (2, 2, 1);
        private var ct:ColorTransform = new ColorTransform (1, 1, 1, 1, 10, 15, 20);

        public function FlashTest() {
            // write as3 code here..
            t = new Timer(500);
	    t.addEventListener(TimerEvent.TIMER, setTet);
	    t.start();

            addEventListener(Event.ENTER_FRAME, loop);
        }
        private function setTet(e:TimerEvent):void{
            for (var i:int = 0; i < 1 + Math.random () * mouseX / 10; i++) {
                var word:String = beaver [beaverIndex];
                beaverIndex ++; beaverIndex %= beaver.length;
                textToBitmap(word,
                    new TextFormat("Helvetica",
                    int (20 + 40 * Math.random ()),
                    null,true)); 
            }
            if (bmp == null) {
                bmp = new Bitmap(bmd);
                addChild(bmp);
            }
            t.delay = Math.min (Math.max (10, 500 - mouseX), 500);
	}

        private function loop (e:Event):void {
            bmd.applyFilter (bmd, bmd.rect, bmd.rect.topLeft, bf);
            bmd.colorTransform (bmd.rect, ct);
        }

        private var m:Matrix = new Matrix;
		
	private function textToBitmap(text : String, tfmt : TextFormat) : void {
            var tf : TextField = new TextField();	
            tf.autoSize = TextFieldAutoSize.LEFT;
            tf.defaultTextFormat = tfmt;
            tf.text = text;
	    //tf.background = false;
            m.tx = (465 - tf.textWidth) * Math.random ();
            m.ty = (465 - tf.textHeight) * Math.random ();
            bmd.draw(tf, m);
        }
    }
}