I am having some trouble with LoaderMax when trying to create a "slideshow" of various asset types.
I am using parse() to load an array of SWFs and mp4 files.
Now, I can add everything to an array and I can seem to play the first SWF using content.rawContent.play(); but then I'm totaly stuck on how to play the next file which is an mp4 video.
I'm not even sure if I should add the loader content to an array?
In the end, I want to be able to loop through a handful of files saved locally without causing a memory leak. I can do this without LoaderMax, but the assets stay in memory and eventually all the RAM is eaten up.
The website makes LoaderMax seem the best solution, but I simply do not know how to implement what I want it to do.
I have searched and no one has tried loading different asset types in a loop, so I am stuck.
Below is my current code, but I'm stuck on how to advance and make the files play one after another, ideally from an array or the loader itself (does the loader store the file data?) so as to not load the file afresh each time.
function loadAssets(playListXml):void
{
LoaderMax.activate([ImageLoader, SWFLoader, VideoLoader]);
var urls:Array = new Array();
for each(var i in playlistXml.playlist.file_path)
{
var file:File = File.userDirectory.resolvePath("test/"+i);
var filePath = file.nativePath;
urls.push("file://"+filePath);
}
queue = LoaderMax.parse(urls,
{maxConnections: 2,
onError: _onErrorHandler,
onComplete: _onCompleteHandler,
onChildComplete: _onChildCompleteHandler,
onProgress: _progressHandler},
{autoPlay: false,
container: container,
width: 1280,
height: 720,
scaleMode: "stretch",
y: 0,
x: 0});
queue.load();
}
function _onErrorHandler(e:LoaderEvent):void
{
trace(e.text);
}
function _progressHandler(e:LoaderEvent):void {
trace(e.target.progress);
}
function _onChildCompleteHandler(e:LoaderEvent):void {
trace(e.target + " loaded");
e.target.content.visible = false;
}
function _onCompleteHandler(e:LoaderEvent):void {
trace("all swfs loaded");
}
Hope you can help!
EDIT: Would it be best to use a LoaderMax XML file to achieve this? I am interacting with an API on a server to get the playlist order, so I could easily get a XML file that LoaderMAx can read (listing the proper loaders etc) Will LoaderMax be able to play the files in sequence and order if i feed it the XML?