I’ve just made a preloader, which is a separate file that loads the main movie. When I try to compile the preloader, I get:
ArgumentError: Error #2068: Invalid sound.
All the code for the streaming sounds is contained in the main movie, and when I compile the main movie directly it finds all the sounds and plays them with no problem. It’s only when I try to compile the preloader that I get the problem.
Here’s the relevant stuff from the main movie:
import flash.display.MovieClip;
import flash.events.*;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.utils.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
private var musicCount:int = (0);
var mySong0:URLRequest = new URLRequest("music/music_0.mp3");
var sound0:Sound = new Sound();
var mySoundChannel_0:SoundChannel = new SoundChannel();
sound0.load(mySong0);
function playMusic(){
if (musicCount == 0){
mySoundChannel_0 = sound0.play(0,1000);
//Prevents the function from looping
musicCount++
}
}
And here’s the preloader movie. It scales a progress bar - the movie clip called bar_mc - while it load the main movie:
var myrequest:URLRequest=new URLRequest("microbe_muncher_070.swf");
var myloader:Loader = new Loader();
myloader.load(myrequest);
myloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progresshandler);
function progresshandler(myevent:ProgressEvent):void {
var myprogress:Number=myevent.target.bytesLoaded/myevent.target.bytesTotal;
bar_mc.scaleX=myprogress;
percentage_text.text=Math.round(myprogress*100)+"%";
}
myloader.contentLoaderInfo.addEventListener(Event.COMPLETE, finished);
function finished(myevent:Event):void {
addChild(myloader);
removeChild(percentage_text);
removeChild(bar_mc);
removeChild(background_mc);
}