I have an MP3 Player on a website that I created and it plays just fine, however, now the client wants the MP3 to play automatically once the page is launched...I have looked at the actionscript code over and over and cannot figure out how to get the player to autoplay. The actionscript I'm using is below:
stop();
import fl.controls.Slider;
import fl.events.SliderEvent;
var volumeOnMove:Boolean=false;
var maxX:Number=280;
var minX:Number=200;
var diference=maxX-minX;
volumeControl.x=maxX;
volumeControl.addEventListener(MouseEvent.MOUSE_DO WN, controlVolume);
function controlVolume(e:MouseEvent) {
volumeOnMove=true;
}
var seconds:String=String(Math.floor(sound.length/1000)%60);
if (seconds.length==1) {
seconds='0'+seconds;
}
totalText.text=String(Math.floor(sound.length/60000))+":"+seconds;
addEventListener(MouseEvent.MOUSE_UP, notControlVolume);
function notControlVolume(e:MouseEvent) {
volumeOnMove=false;
}
addEventListener(Event.ENTER_FRAME, moveControl);
function moveControl(e:Event) {
if (volumeOnMove==true) {
if (volumeControl.x<=maxX&&volumeControl.x>=minX) {
volumeControl.x=mou***;
}
}
if (volumeControl.x>=maxX) {
volumeControl.x=maxX;
}
if (volumeControl.x<=minX) {
volumeControl.x=minX;
}
if (volumeOnMove==true) {
volSound.volume=((volumeControl.x-minX)*100/80)/100;
channel.soundTransform=volSound;
}
}
pauseButton.visible=false;
var channel:SoundChannel=sound.play();
channel.stop();
var volSound:SoundTransform=new SoundTransform();
volSound.volume=1;
channel.soundTransform=volSound;
var sTime:Number=0;
var iniDateate;
var currentDateate;
var finalDateate;
var isPlay:Boolean=true;
playButton.addEventListener(MouseEvent.CLICK, playSound);
function playSound(e:MouseEvent) {
isPlay=false;
channel=sound.play(sTime);
channel.soundTransform=volSound;
pauseButton.visible=true;
iniDate=new Date();
panel.gotoAndStop(2);
addEventListener(Event.ENTER_FRAME, doSlide);
}
stopButton.addEventListener(MouseEvent.CLICK, stopSound);
function stopSound(e:MouseEvent) {
channel.stop();
isPlay=false;
sTime=0;
pauseButton.visible=false;
panel.gotoAndStop(1);
removeEventListener(Event.ENTER_FRAME, doSlide);
timeSlider.value=0;
}
pauseButton.addEventListener(MouseEvent.CLICK, pauseSound);
function pauseSound(e:MouseEvent) {
channel.stop();
isPlay=false;
pauseButton.visible=false;
finalDate=new Date();
sTime+=Number(finalDate.time-iniDate.time);
panel.gotoAndStop(1);
removeEventListener(Event.ENTER_FRAME, doSlide);
}
timeSlider.maximum=sound.length;
function doSlide(e:Event) {
currentDate=new Date();
if (currentDate&&iniDate) {
var slidePoint=Number(currentDate.time-iniDate.time)+sTime;
timeSlider.value=slidePoint;
}
}
timeSlider.addEventListener(SliderEvent.CHANGE, sliderMove);
function sliderMove(e:SliderEvent) {
sTime=timeSlider.value;
}
timeSlider.addEventListener(MouseEvent.MOUSE_DOWN, stopSlider);
function stopSlider(e:MouseEvent) {
channel.stop();
pauseButton.visible=false;
panel.gotoAndStop(1);
removeEventListener(Event.ENTER_FRAME, doSlide);
}
timeSlider.addEventListener(MouseEvent.MOUSE_UP, startSlider);
function startSlider(e:MouseEvent) {
if (isPlay==false) {
channel=sound.play(timeSlider.value);
pauseButton.visible=true;
panel.gotoAndStop(2);
iniDate=new Date();
addEventListener(Event.ENTER_FRAME, doSlide);
}
}
addEventListener(Event.ENTER_FRAME, setText);
function setText(e:Event) {
var seconds:String=String(Math.floor(timeSlider.value/1000)%60);
if (seconds.length==1) {
seconds='0'+seconds;
}
currentText.text=String(Math.floor(timeSlider.valu e/60000))+":"+seconds;
}
addEventListener(Event.ENTER_FRAME, end);
function end(e:Event) {
if (timeSlider.value==sound.length) {
removeEventListener(Event.ENTER_FRAME, doSlide);
iniDate=new Date();
channel.stop();
isPlay=false;
sTime=0;
pauseButton.visible=false;
panel.gotoAndStop(1);
timeSlider.value=0;
}
}
Any help would be GREATLY appreciated.
Thanks,
KJ


Reply With Quote


Bookmarks