Hi,
I have the following code which is working quite nice. But the problem is, it won’t check whether the requested page is already loaded or not. It simply loads the page whenever the related buttons is pressed.
What I need is, if I click on home button, first the code should check whether the “Home” page is already loaded or not. If already loaded, it should do nothing. If not then it should load the “Home” page.
How can I resolve this problem by adding some extra code to it? Please help.
var timer:Timer = new Timer(3000, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
timer.start();
function onTimerComplete(e:TimerEvent):void {
var X1pos:Number = 0;
var Y1pos:Number = 0;
var SWF1:MovieClip;
var loader1:Loader = new Loader();
var defaultSWF:URLRequest = new URLRequest("Welcome.swf");
loader1.load(defaultSWF);
loader1.x = X1pos;
loader1.y = Y1pos;
MainContainer.SWFContainer.addChild(loader1);
//---------------------------------------------------------------------------------------
MainContainer.NavigationPanel.Home.addEventListener(MouseEvent.CLICK, btnClick);
MainContainer.NavigationPanel.PortFolio.addEventListener(MouseEvent.CLICK, btnClick);
MainContainer.NavigationPanel.Contacts.addEventListener(MouseEvent.CLICK, btnClick);
function btnClick(event:MouseEvent):void {
MainContainer.SWFContainer.removeChild(loader1);
var newSWFRequest:URLRequest = new URLRequest(event.target.name + ".swf");
//var newSWFRequest:URLRequest = new URLRequest("SWFFiles/" + event.target.name + ".swf");
loader1.load(newSWFRequest);
loader1.x = X1pos;
loader1.y = Y1pos;
MainContainer.SWFContainer.addChild(loader1);
}}
Thanks for any help.
Regards.