Hi guys just a quick one (that’s what she said) I have four buttons on my index page and I want to load a new swf to the centre of the stage every time I click one of these buttons. I can do this but I can’t remove then existing swfs please help!!
public class Index extends MovieClip
{
public var button:buttonMc;
public var aboutText:aboutTextMc;
public var portText:PortfolioTextMc;
private var portBool:Boolean = false;
private var aboutBool:Boolean = false;
private var contactBool:Boolean = false;
private var clientBool:Boolean = false;
public var file:String;
public var swfBoolean:Boolean = false;
public function Index()
{
button = new buttonMc();
addChild(button);
button.x = 450;
button.y = 480;
var container:Sprite = new Sprite();
this.addEventListener(MouseEvent.CLICK, isPressed);
function isPressed(event:MouseEvent):void
{
if (event.target=="[object portButtonMc]")
{
file = "portfolio";
}
else if (event.target=="[object aboutButtonMc]")
{
file = "about";
}
else if (event.target=="[object contactButtonMc]")
{
file = "contact";
}
else if (event.target=="[object clientButtonMc]")
{
file = "client";
}
if (swfBoolean)
{
//container.removeChild(swf);
swfBoolean=false;
swf.unload();
}
else if (swfBoolean=false);
{
}
var swfRequest:URLRequest = new URLRequest(file+".swf");
var swf:Loader = new Loader();
swf.load(swfRequest);
swf.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
swf.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preloader);
function preloader(event:ProgressEvent):void
{
var percent:Number = Math.round(event.target.bytesTotal / event.target.bytesTotal* 100);
preload.text = String(percent) + "%";
addChild(preload);
}
function onComplete(event:Event):void
{
addChild(container);
container.addChildAt(swf, 0);
swf.x = 100;
swf.y = 230;
removeChild(preload);
swfBoolean=true;
}
}
}
}
}