Button menu to load swf's
I have been reading tutorials and learning flash. Forgive my "newbie-ness".
I am trying to make a menu that loads external swf's into my current movie.
Here is the code that I have, which does what I want, except the buttons only work in order... you can't click the last one first, for example... They only work in the order in which the button variables are scripted... well here....don't laugh.. i am sure there is a better way. ![]()
import fl.controls.Button;
var my_loader:Loader = new Loader();
addChild(my_loader);
var about_btn:Button = new Button();
about_btn.label="ABOUT";
about_btn.x=50;
about_btn.y=550;
addChild(about_btn);
var gallery_btn:Button = new Button();
gallery_btn.label="GALLERY";
gallery_btn.x=250;
gallery_btn.y=550;
addChild(gallery_btn);
var contact_btn:Button = new Button();
contact_btn.label="CONTACT";
contact_btn.x=450;
contact_btn.y=550;
addChild(contact_btn);
var partners_btn:Button = new Button();
partners_btn.label="PARTNERS";
partners_btn.x=650;
partners_btn.y=550;
addChild(partners_btn);
about_btn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void {
my_loader.load(new URLRequest("aboutFlash.swf"));
gallery_btn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void {
my_loader.load(new URLRequest("galleryFlash.swf"));
contact_btn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void {
my_loader.load(new URLRequest("contactFlash.swf"));
partners_btn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void {
my_loader.load(new URLRequest("partnersFlash.swf"));
}
}
}
}
I have been looking at so many snipets and such.. and whats with all the brackets at the end... I kept adding them until it wasn't expecting right bracket at end of program anymore. Like I said, it works but you have to click "about" first and so on down the list, once through, then what ever order after you have loaded them all once.
Rick
