Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Simple test to illustrate a small audio latency in the PPAPI version of the Flash plugin in Chrome.
.DS_Store
package { import flash.events.MouseEvent; import flash.media.Sound; import flash.geom.ColorTransform; import flash.geom.Transform; import flash.media.SoundTransform; import flash.display.MovieClip; import flash.events.Event; import flash.text.TextField; import flash.system.Capabilities; // Simple demonstration of sound lag in PPAPI Flash. public class SoundTestApp extends MovieClip { // Stage variables public var version:TextField; public var trigger:MovieClip; // Create the sound from the embedded audio. // It is embedded as a 44kHz stereo 16 bit sound. var sound:Sound = new audio_clip(); public function SoundTestApp() { addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } private function onAddedToStage(event:Event):void { removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); // Display the flash version version.text = "Flash version: " + Capabilities.version + (Capabilities.isDebugger ? " Debug" : " Release"); // Play the clip silently on start so there is no // initial delay when triggering it. sound.play(0, 0, new SoundTransform(0)); // Wire up the events trigger.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver); trigger.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); } // Play the sound and change the square to red when mouse // over occurs private function onMouseOver(event:MouseEvent):void { var t:Transform = trigger.background.transform; var ct:ColorTransform = trigger.background.transform.colorTransform; ct.color = 0xff0000; t.colorTransform = ct; sound.play(); } // Change the square to blue when mouse out occurs private function onMouseOut(event:MouseEvent):void { var t:Transform = trigger.background.transform; var ct:ColorTransform = trigger.background.transform.colorTransform; ct.color = 0x0066cc; t.colorTransform = ct; } }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment