Hello, I am new to Greensock classes, and I am very happy with it. Please be patient with me.
I am adding an mp3 player to a flash website, I am trying to do it very easy,
with a combobox selector in order to choos from 5 or 6 music styles (I don't need the
information of the artist, nor the song title etc.) and just on/off toggle button and probably
a volume slider. very minimal; I want to use an XML file to reference all my mp3 files and
I want to use mp3Loader. I chose the combobox so when I change to a different music style,
the music fades out and the new one fades in.
With the code I have written so far, I have named the music style options in the combobox
and the combobox format, and I am usin mp3loader to load an external mp3, and a sound_mc
movieclip to toggle the sound on/off with a hit button area.
Any help?
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.plugins.*;
//Inicicalize ComboBox
stop();
combo.addItem( { label: "Ambient "} );
combo.addItem( { label: "Experimental "} );
combo.addItem( { label: "Relax "} );
var myFormat:TextFormat=new TextFormat()
myFormat.size=12;
myFormat.color=0xFFFFFF
combo.textField.setStyle("textFormat",myFormat)
combo.dropdown.setRendererStyle("textFormat",myFormat)
/////////////////////////////////////////////////////////////////
TweenPlugin.activate([VolumePlugin]);
import flash.events.MouseEvent;
sound_mc.alpha = 0;
var sound:MP3Loader = new MP3Loader("audio/Relax.mp3", {onComplete:init, volume:0, autoPlay:true, repeat:-1});
sound.load();
var soundOn:Boolean = false;
//wait for the sound to load
function init(e:LoaderEvent):void
{
TweenLite.to(sound_mc, .5, {alpha:1});
hit_sound_btn.addEventListener(MouseEvent.CLICK, toggleSound);
}
function toggleSound(e:MouseEvent):void
{
//switcheroo
soundOn = ! soundOn;
var myValue:int = int(soundOn) // converts true to 1, false to 0
TweenLite.to(sound, 1.5, {volume:myValue});
sound_mc.gotoAndStop(myValue + 1); // frame numbers start at 1
}