PDA

View Full Version : External swf and sound playback problems



igreg2409
June 9th, 2009, 06:46 AM
Hi,

Like the title suggests i have two problems, and they both occur when i try and run my swf file online, it works fine offline.

1. Basically I embedded my preloader swf in a html page and uploded it for testing. Then i tested it and it just refuses to load in the external swf. here's the code, i assume i have made a rookie error here:


var req:URLRequest = new URLRequest("main.swf");
var myLoader:Loader = new Loader();

myLoader.load(req);
addChild(myLoader);
myLoader.alpha = 0;

myLoader.contentLoaderInfo.addEventListener(Event. COMPLETE, onComplete);

function onComplete(e:Event){
addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event){
holder.alpha -= 0.2;
myLoader.alpha += 0.1;
}

}2. I decided to just try and run the main swf without the preloader and it all works fine apart from the sound. The sound will not play, but it plays perfectly offline. I have uploaded the music file it needs and placed it in the same folder so that cant be it. Neway here's the code i use to play the sound, i assume the problem is here:


var soundChannel:SoundChannel = new SoundChannel();
var s:Sound = new Sound(new URLRequest("piano.mp3"));
var soundTrans:SoundTransform = new SoundTransform();

soundChannel = s.play(0,int.MAX_VALUE);
soundTrans.volume = 0.3;
soundChannel.soundTransform = soundTrans; If anyone can help that ould be awesome, thanks.