Hi guys, thanks for all the support and documentation you have made available online. I’m quite surprised that I did not find a solution this problem on my travels. So I hope that you can make sense of it.
I am using loadermax in a preloader swf to load up an asset heavy swf (a game I'm working on). When I test it online the game loads incorrectly, throwing up assets that shouldn't be there.
However I tried to work around this problem (which was most likely my fault for coding on the timeline) By using loadermax to reference the raw content of the game during the load onComplete function, calling a function that exists in the loaded swf that sorts it all out.
This solution worked out well, when I tested the container in the flash IDE the raw reference worked, but for some reason the rawContent call is not getting made when run in a browser.
Below is my code for the swf container
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
import flash.events.Event;
import com.greensock.easing.*;
var loader:SWFLoader = new SWFLoader("http://www.oliart.co.uk/schooloffish/school of fish.swf",{container:this,onProgress:progressHandler,noCache:true,onInit:completeHandler,onChildComplete:completeHandler,onComplete:completeHandler,onError:errorHandler,estimatedBytes:3796000});
var xload:int = 0;
var endofload:Boolean = true;
var rideaway:Boolean = false;
var fadeaway:Boolean = false;
loader.load();
playbutton.alpha = 0;
//mouse and frame events
addEventListener(Event.ENTER_FRAME, cycleload);
addEventListener(MouseEvent.MOUSE_DOWN, playgame);
//progress display
function progressHandler(event:LoaderEvent):void
{
trace("progress: " + xload);
xload = Math.round(event.target.progress * 100);
loadtext.text = "DISTANCE: " + (2.5- (int((event.target.progress * 2.5)*100)/100)) + "Mile(s)";
}
function completeHandler(event:LoaderEvent):void
{
var mc:MovieClip = loader.rawContent;
mc.preloadfix(); // ---------------------- This is not getting called
}
function errorHandler(event:LoaderEvent):void
{
trace("error occured with " + event.target + ": " + event.text);
}
function cycleload(e:Event):void
{
setChildIndex(playbutton,numChildren-1);
setChildIndex(loadtext,numChildren-2);
setChildIndex(ride,numChildren-3);
setChildIndex(fadeclip,numChildren-4);
//check for when the loading is near completion
if (xload >= 94 && endofload== true)
{
//endfunction triggers the play button tween
endfunction();
}
if (ride.x > 0)
{
//loading bar position
ride.x = 800 - (xload * 8);
}
}
//remove events at after loading
function removeall():void
{
removeChild(fadeclip);
removeChild(ride);
removeChild(playbutton);
removeChild(loadtext);
removeEventListener(Event.ENTER_FRAME, cycleload);
removeEventListener(MouseEvent.CLICK, playgame);
}
//moves button into position after load
function endfunction():void
{
TweenLite.to(playbutton, 5 , {alpha:1, y:400, ease:Back.easeOut});
TweenLite.to(loadtext, 2 , {alpha:0});
endofload = false;
}
//play button fades out movieclip to reveal game
function playgame(e:MouseEvent):void
{
if (e.target == playbutton && xload == 100)
{
TweenLite.to(fadeclip, 4 , {alpha:0, delay:2, onComplete: removeall});
TweenLite.to(ride, 2 , {x:-300});
TweenLite.to(playbutton, 2 , {alpha:0});
}
}
You can take a look at the game with the described issues for reference http://oliart.co.uk/schooloffish/
Refreshing the page seems to get it to work, but its hardly an ideal solution.
Is this an issue with loadermax or am I doing something wrong here?