add a COMPLETE event listener to the swf loader, e.g. ActionScript Code:
[LEFT]swfLoader.[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR]Event.[COLOR=#000080]COMPLETE[/COLOR], onSwfLoadComplete[COLOR=#000000])[/COLOR];
[/LEFT]
then under the onSwfLoadComplete function, set a boolean variable to true, e.g.
then on the mouse event function you have written above, do something like:
ActionScript Code:
[LEFT][COLOR=#000000]function[/COLOR] [COLOR=#0000FF]ButtonPressed[/COLOR]COLOR=#000000[/COLOR]:[COLOR=#0000FF]void[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR] COLOR=#000000[/COLOR]
[COLOR=#000000]{[/COLOR]
imageLoader.[COLOR=#0000FF]load[/COLOR]COLOR=#000000[/COLOR];
container_mc.[COLOR=#000080]addChild[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[/LEFT]
i chnaged your function name from Button to ButtonPressed as tbh Button as a function name isnt very good practice, e.g. conflicting function name with the Button class etc
I thought I had it working. What I should have mentioned before was that I wanted this button to keep loading a series of swf files. So I wanted to continue the conditional statement to check and see if a swf was loaded. If not to ignore it, then go on to the next statement…etc. Here’s how I tried to extednd the code:
stop();
var imageRequest1:URLRequest = new URLRequest("1.swf");
var imageRequest2:URLRequest = new URLRequest("2.swf");
var imageRequest3:URLRequest = new URLRequest("3.swf");
var imageLoader:Loader = new Loader();
var swfLoaded:Boolean;
next_mc.addEventListener(MouseEvent.CLICK, ButtonPressed);
imageLoader.addEventListener(Event.COMPLETE, onSwfLoadComplete);
imageLoader.load(imageRequest1);
container_mc.addChild(imageLoader);
function onSwfLoadComplete(event:Event):void {
swfLoaded = true;
}
function ButtonPressed(event:MouseEvent):void {
if ("1.swf") {
imageLoader.load(imageRequest2);
container_mc.addChild(imageLoader);
} else if ("2.swf") {
imageLoader.load(imageRequest3);
container_mc.addChild(imageLoader);
}
}
next_mc.buttonMode = true;
I tried this but it keeps loading 2.swf even after 2.swf has loaded. Any thoughts, on how I might fix this?