Ciao a tutti ragazzi e buon anno,
ho scaricato dalle risorse in flash un player in actionscript e vorrei che la musica partisse da sola, ma non so cosa devo cambiare,
mi potreste aiutare?
Grazie.
codice:stop(); // numbers needed for the visuals, you can play around with altering them const PLOT_HEIGHT:int = 11; const CHANNEL_LENGTH:int = 100; // Byte array also needed for the visuals var bytes:ByteArray = new ByteArray(); // Assign The mp3 to play var req:URLRequest = new URLRequest("song.mp3"); // Boolean value for button functions, to switch in the conditionals var isPlaying:Boolean = false; // Create the sound object var snd:Sound = new Sound(req); // Assign a var name for the sound channel var channel:SoundChannel; // Play Button Listener /////////////////////////////////////////////////////////////////////// playBtn.addEventListener(MouseEvent.CLICK, playPause); /////////////////////////// Start Play button function ////////////////////////////////////////////////////// function playPause(event:MouseEvent):void { // This conditional makes the magic of our play/pause functionality if (isPlaying == false) { channel = snd.play(); // Start playing isPlaying = true; } // Stop button listener and function stopBtn.addEventListener(MouseEvent.CLICK, stopSound); function stopSound(event:MouseEvent):void { channel.stop(); isPlaying = false; } // On playback complete listener and function, needed to reset some things channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete); function onPlaybackComplete(event:Event) { isPlaying = false; //trace("The sound has finished playing."); } } /////////////////////////// End Play button function ////////////////////////////////////////////////////// // Add listener to trigger [onEnterFrame] function below, needed for our amplitude animation addEventListener(Event.ENTER_FRAME, onEnterFrame); function onEnterFrame(event:Event):void { SoundMixer.computeSpectrum(bytes, false, 0); var g:Graphics = this.graphics; g.clear(); g.lineStyle(0, 0x82C0FF); g.beginFill(0x82C0FF, 0.5); g.moveTo(0, PLOT_HEIGHT); var n:Number = 0; // left channel for (var i:int = 0; i < CHANNEL_LENGTH; i++) { n = (bytes.readFloat() * PLOT_HEIGHT); g.lineTo(i * 2, PLOT_HEIGHT - n); } g.lineTo(CHANNEL_LENGTH * 2, PLOT_HEIGHT); g.endFill(); // right channel g.lineStyle(0, 0xFFCC00); g.beginFill(0xFFCC00, 0.5); g.moveTo(CHANNEL_LENGTH * 2, PLOT_HEIGHT); for (i = CHANNEL_LENGTH; i > 0; i--) { n = (bytes.readFloat() * PLOT_HEIGHT); g.lineTo(i * 2, PLOT_HEIGHT - n); } g.lineTo(0, PLOT_HEIGHT); g.endFill(); } // END onEnterFrame Function

Rispondi quotando