Flash
- Started
- Last post
- 4 Responses
- lw-d
Hi all,
On day 2 of learning ActionScript. Here is what I am trying to do.
Create a variable to hold details of what button a user has pressed, then, create a function that acts upon this variable out outputs the relevent page. I have no objects on the actual timeline but I have give set the linkage options for each menu from the library. Here is the code I have:
//creates a variable to store the currently active menu
storepage = home;// creates a function that tell flash which menu to show
loadnav = function (storepage) {
if (storepage = "modeling") {
nav_modeling = this.attachMovie("nav_modeling", "nav_modeling_mc","0",{_x:25, _y:108.8});
}else if (storepage = home) {
nav_home = this.attachMovie("nav_home", "nav_home_mc","0",{_x:25, _y:108.8});
}
}it doesn't display the default menu name home, can anyone see an obvious reason why?
Thanks
- restlessdesign0
well...where are you calling the function?
anyways, if you're going to be doing a lot of logic testing, i would suggest using a SWITCH statement instead of a bunch of IF statements
for the way you're doing it, you don't even really need to pass any parameters to your function. you could just make a global variable:
_global.thePage = "home"
and change the value of that variable whenever a button is clicked, then call a function to load it:function loadPage() {
switch (_global.thePage) {
case "home" :
some_mc.loadMovie("home.swf")
break;
}
}etc.
- lw-d0
Thanks mate, I will look in SWITCH statements, just found it a chapter in a book I am learning from.
Thanks.
- lw-d0
awesome: I know have the home menu movie loaded using:
switch (loadnav) {
case home: nav_home = this.attachMovie("nav_home", "nav_home_mc","0",{_x:25, _y:108.8});
case modeling: nav_modeling = this.attachMovie("nav_modeling", "nav_home_mc","0",{_x:25, _y:108.8});
case visual: nav_visual = this.attachMovie("nav_visual", "nav_home_mc","0",{_x:25, _y:108.8});
default: nav_home = this.attachMovie("nav_home", "nav_home_mc","0",{_x:25, _y:108.8});
}I know just need to wire up the buttons.
Thanks for your help.
- restlessdesign0
anytime :)