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: 声で大きくなる元気玉っ!

Get Adobe Flash player
by tests2090 13 Sep 2012
    Embed
/**
 * Copyright tests2090 ( http://wonderfl.net/user/tests2090 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/g8Ue
 */

// forked from ameo's 声で大きくなる元気玉っ!
package {
    import flash.display.*;
    import flash.events.*;
    import flash.media.*;
    import org.papervision3d.materials.*;
    import org.papervision3d.objects.primitives.*;
    import org.papervision3d.view.*;
    import flash.media.Microphone;
    import flash.media.SoundMixer;
    import flash.media.SoundTransform;
    [SWF(width = 300, height = 300, frameRate = 60)]

    public class MicExam extends BasicView {
        private var mic:Microphone;
        private var sphere:Sphere;

        public function MicExam() {
            // 背景を黒に設定
            viewport.opaqueBackground = 0x000000;
            //マイク
            mic = Microphone.getMicrophone();
            if (mic != null) {
            mic.setLoopBack(true);
            mic.gain = 50;
            mic.rate = 11;
            mic.setSilenceLevel(5);
            //ハウリング対策?
            SoundMixer.soundTransform = new SoundTransform(0);
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
            
            // 球体を作成
            var material:WireframeMaterial = new WireframeMaterial(0x0099FF);
            sphere = new Sphere(material, 800, 20, 20);
            scene.addChild(sphere);

            }
            // レンダリング
            startRendering();
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }

        private function onEnterFrame(e:Event):void {

            // 球体のスケールを制御
            sphere.scale -= 0.01;
            sphere.scale = Math.max(mic.activityLevel*0.01,sphere.scale);
            
            // 球体の回転を制御
            sphere.rotationX += Math.max(mic.activityLevel) *2;
            sphere.rotationY += Math.max(mic.activityLevel) *4;
        }

    }
}