Help with flash website - dynamic page indicator

Hello All,

This is my first time posting here. I am new Flash and actionscripting, but I just want to say hi and thanks in advance for any help you all can provide. That said, here is the problem.

I have a website, basic overview. I have my main movie, which contains the logo and navigation. I have a blank movieclip created with actionscript that loads the individual movie swf files. That works fine.

What I want to do, and which I can’t figure out is dynamically have the main navigation buttons’ text indicate what page you the user is on. Right now the code is on each button instance, example:

 
//work button Definition
on(press){
 if(_root.pageHolder != "work") {
  _root.pageHolder = "work";
  _root.mcContainer.loadMovie(_root.pageHolder+".swf", this);
  //_root.work.gotoAndStop(2);
  _root.setCurrentMarker();	//this the line that calls the function for setting the page indicator
 }
}
on(rollOver){
 if(this._currentframe == 1){
  this.work.textColor =0x000000;
 } else {
  null;
 }
}
on(rollOut){
 if(this._currentframe == 1){
  this.work.textColor =0x707070;
 } else {
  null;
 }
}
 

I posted the whole code because I have another question. Each button has the same code, just pointing to their respective pages.

Here is the code in the first frame for setCurrentMarker()n function:

 
var aMenu = new Array(home, jschaer, work, contact); 
 
function setCurrentMarker(){
 for(i=0; i<= (_root.aMenu.length-1); i++){
	if(_root.aMenu* == pageHolder){
	  _root.aMenu*.gotoAndStop(2);
	  trace("called if true");
  } else if(_root.aMenu* == _root.pageHolder){
	  _root.aMenu*.gotoAndStop(1);
  }
 }
}

so the variable aMenu holds the moveclip names of the buttons. pageHolder holds the the name of the current page that is loaded. Thats how I change the pages to be loaded. To explain, if you look at the button code, the text for each button is by default greay and when you rollover it becomes black and off and it becomes gray again. That is on the first frame. On the second frame the text is black.

In the code I tried to make the black dynamically, but it didn’t work, so I settled for going to the second frame and stopping.

I am sorry this is long, do you understand what I am trying to do? Do I need to explain less, and how do you get those little scroll boxes where you can put code.

My second question(much shorter I promise). I guess its preference, but is it generally good to put the code on each instance of a button or put in in the main frame where your code lies. Is there any benefit either way?

Sorry for the essay,
Brian