Preloading dynamic images and sound

Hi all,

1st things 1st, i’m a php developer and have a very limited knowledge of actionscript’s syntax, functions and capabilities. i’ve been trying this in AS2 as it’s what i’ve used before but if necessary i can switch to AS3 if it’s the only way of making this possible.

i’ve built what will be a template swf which will then load a series of 6 images, 2 audio tracks (background music and a voice over script) and a custom header and footer image, the names and paths of which are all returned by a php script.

i’ve got the images displaying fine, and the sound plays when i test locally but when i “simulate download” in the publish preview it all goes to pot. the sound doesn’t cut in until a fair way through the 45 second presentation and my series of images appear only at the end of each transition (i have them set to fade in as the previous one fades out) which means that as the previous one fades out, the next one just appears rather than coming in gracefully.

obviously i need to preload everything, but even after trawling google and a whole host of tutorials i can’t get it working. i’ve tried 3 different preloaders (one from istock and 2 from tutorials) and modified the code for each to what i believe should work.

some tutorials mention attachSound whilst others say use loadSound. some say to use an external swf to preload the sound whilst others have clearly managed to get it working in the parent swf in their tutorials.

i’ve written, scrapped, planned, re-written and scrapped so many different scripts now i’ve lost my way! i think that the sound isn’t being started to download until it’s required in the movie, even though i need to access it straight away. if i’d got it in the timeline i don’t think it would be an issue but that’s not an option for me.

i’d appreciate it if someone could give me a quick rundown of the procedure and outline the coding steps i need to address. i’m not asking you to write it for me (that defeats the point of trying to learn), just to outline the program flow and help me on my way. i’ve had a quick look around here and seen examples from some talented flash programmers so i’m hoping this is the forum to ask!

i’'ve only hard-coded the image and sound file paths in to the actionscript so far, but i’ve managed to query php scripts with flash before so i can’t see that being too difficult once i look up my old code. i imagine the program flow would look something like this (in a very brief outline), so i’d be grateful if someone could put it into a more code-like manner to get me going!

1: use loadVars to connect to the php script and retrieve the file names and paths of images and sound
2: use getBytesTotal for each image and audio file to determine the total size of the dynamic elements
3: start downloading the objects (how do i force the download to start?)
4: use getBytesLoaded to check how much has been downloaded so far
5: display that in a preloader
6: once getBytesLoaded == getBytesTotal, play the animation from frame 2 onwards.

cheers!

Neal.