Here's the class:
package {
///
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.*;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.media.SoundMixer;
import flash.net.URLRequest;
import flash.utils.Timer;
import flash.utils.ByteArray;
///
// GreenScock TweenLite / TweenMax - Version: 11.1, Updated 10/21/2009
///
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
///
public class music extends Sprite {
///
// VARIABLES
///
private var url:String;
private var boton:MovieClip;
private var song:SoundChannel;
private var soundFactory:Sound;
private var FourierTransform:Boolean = false;
private var arrayMixer:ByteArray = new ByteArray();
private var pan:int = 0;
private var porcentLoad:Number = 0;
private var pausePoint:Number = 0.00;
private var isStarted:Boolean = true;
/*----------------------- INIT -----------------------*/
/*----------------------- INIT -----------------------*/
/*----------------------- INIT -----------------------*/
/*----------------------- INIT -----------------------*/
/*----------------------- INIT -----------------------*/
/*----------------------- INIT -----------------------*/
public function music():void {
///
}
/*----------------------- UTILS -----------------------*/
/*----------------------- UTILS -----------------------*/
/*----------------------- UTILS -----------------------*/
/*----------------------- UTILS -----------------------*/
/*----------------------- UTILS -----------------------*/
/*----------------------- UTILS -----------------------*/
public function cargarMusic(mp3:String, que_boton:MovieClip):void {
///
url = mp3;
boton = que_boton;
pausePoint = 0.00;
///
SoundMixer.stopAll();
soundFactory = new Sound();
var request:URLRequest = new URLRequest(url);
///
soundFactory.addEventListener(Event.COMPLETE, completeHandler);
soundFactory.addEventListener(ProgressEvent.PROGRESS, progressHandler);
soundFactory.load(request);
}
public function execMusic(e:MouseEvent):void {
///
if(isStarted){
///
TweenLite.to(song, 1, {volume:0, onComplete:pauseMusic});
///
isStarted = false;
}
else{
///
song = soundFactory.play(pausePoint);
song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
///
TweenLite.to(song, 0, {volume:0});
TweenLite.to(song, 2, {volume:1});
///
isStarted = true;
}
///
MovieClip(boton.parent).clickMusicaHome();
}
public function playMusic():void {
///
song = soundFactory.play(pausePoint);
song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
///
//TweenLite.to(song, 0, {volume:0});
//TweenLite.to(song, 5, {volume:1});
}
public function pauseMusic():void {
///
pausePoint = song.position;
song.stop();
}
public function loopMusic():void {
///
pausePoint = 0.00;
song = soundFactory.play(pausePoint);
song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
}
private function soundCompleteHandler(e:Event):void {
///
song.removeEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
loopMusic();
}
public function get MixerMusic():ByteArray {
///
SoundMixer.computeSpectrum(arrayMixer, FourierTransform);
return arrayMixer;
}
public function set FourierMusic(valor:Boolean):void {
///
this.FourierTransform = valor;
}
public function get FourierMusic():Boolean {
///
return FourierTransform;
}
/*----------------------- LISTENERS -----------------------*/
/*----------------------- LISTENERS -----------------------*/
/*----------------------- LISTENERS -----------------------*/
/*----------------------- LISTENERS -----------------------*/
/*----------------------- LISTENERS -----------------------*/
/*----------------------- LISTENERS -----------------------*/
private function completeHandler(event:Event):void {
///
playMusic();
MovieClip(boton).lines_mc.play();
}
private function progressHandler(event:ProgressEvent):void {
///
porcentLoad = Math.round((event.bytesLoaded*100)/event.bytesTotal);
}
}
}
In there if I remove the comments from the playMusic function tween volumes it gives me the error I mentioned... And the plug-in isn't active :S
Weirddddddddddddddd...
Usage like this:
var music_home:music = new music();
music_home.cargarMusic("music/music_site.mp3", music_mc);
Hope it helps...