Friday, November 4, 2011

Code Option for the Welcome .fla

This will remove the Intro.fla AND the Title.fla after you click the Play/Stop, Direction buttons. The previous version removed the Intro, but kept the Title on the Stage.

---------------------

var titleLoader:Loader = new Loader();
//create new URLRequest and fill it
var titleSWF:URLRequest = new URLRequest("Title.swf");

//load the loader
titleLoader.load(titleSWF);
//position the loader on the page
titleLoader.y = 0;
titleLoader.x = 0;
//add the loader to the page
addChild(titleLoader);

//*******************************************************

var mainLoader:Loader = new Loader();
//create new URLRequest and fill it
var defaultSWF:URLRequest = new URLRequest("Intro.swf");

//load the loader
mainLoader.load(defaultSWF);
//position the loader on the page
mainLoader.y = 0;
mainLoader.x = 0;
//add the loader to the page
addChild(mainLoader);

//*******************************************************

function step(event:MouseEvent):void {

removeChild(mainLoader);
var direct_url:URLRequest = new URLRequest("Directions.swf");
mainLoader.load(direct_url);
addChild(mainLoader);
removeChild(titleLoader);

}

function ani(event:MouseEvent):void {

removeChild(mainLoader);
var ani_url:URLRequest = new URLRequest("start_stop.swf");
mainLoader.load(ani_url);
mainLoader.y = 150;
mainLoader.x = 150;
addChild(mainLoader);
removeChild(titleLoader);
}

//event listeners which run function btnClick for CLICK event of each button

step_btn.addEventListener(MouseEvent.CLICK, step);
aniPlay_btn.addEventListener(MouseEvent.CLICK, ani);

-----------------