[FMX] Custom Function - any help appreciated :)

Hi there actionscripters

 I'm a complete newb when it comes to AS & PHP, I to tend *think* I know what i'm doing but usually don't. [img]http://forums.ultrashock.com/forums/images/smilies/biggrin.gif[/img]
 
 I have an idea on how I'd like my current project to work, but no idea how to code it correctly.

Basically I have 8 sections to my flash movie, (pages) - and a library of mcs that get used differently depending on the current page.

I’m trying to make a global function that can control the mc’s on each section when a navigation button is pressed. For instance, the home page uses 3 mcs from the library, and the services page uses 5 mcs from library. I want my function to know which mc’s are used on every page, and also which mc’s are currently showing on screen.

e.g : When a nav button is pressed, my function creates a list of which mc’s are to be used next, and then performs the following operations:

** 1. function knows which mc’s are currently onscreen
2. function fades them out one at a time til they are all gone.
3. function knows which mc’s are to be used next (which ones are on the page that was selected)
4. function fades them in one by one til they are visible.**

 Please excuse my complete newb-ness whilst I try to describe this by the way!

I tried to write a script which perfoms what I need - however my knowledge of AS is so poor I had to use some PHP code in places. What I’m hoping for is that someone can understand the idea behind my pathetic code and help me write a working AS method.

 Anyway here goes:

      [color=#000087]function[/color] pageControl (page){
       switch (page){
                    
       case "[color=blue]homepage[/color]":
                    
       [color=#878787]// make the array containing which mc's are used on this page
    [/color]   newMovieList[1] = "[color=blue]menuMc[/color]";
       newMovieList[2] = "[color=blue]jukeMc[/color]";
       newMovieList[3] = "[color=blue]textBoxMc[/color]";
       newMovieListCount = 3;
    
     [color=#000087]function[/color] fader(){
     i = 1;
       [color=#000087] while[/color] (i < movieListCount) {
        fadeOut(movieList*);
        [color=#878787]// add some sort of 1 sec delay here
    [/color]    i++;
        }
       [color=#000087]  while[/color] (j < newMovieListCount){
         fadeIn(newMovieList[j]);
       [color=#878787]  // 1 sec delay
    [/color]     j++;
         }
         movieList = newMovieList;
         movieListCount = newMovieListCount;
       [color=#878787]  // clear up ready for the next batch
    [/color]     newMovieList = "";
         newMovieListCount = "";
         } [color=#878787]// end fader
    [/color]   [color=#000087]break[/color];
                    
       case "[color=blue]services[/color]":
                    
       [color=#878787]// make the array containing which mc's are used on this page
    [/color]   newMovieList[1] = "[color=blue]menuMc[/color]";
       newMovieList[2] = "[color=blue]pictureBoxMc[/color]";
       newMovieList[3] = "[color=blue]jukeboxMc[/color]";
       newMovieList[4] = "[color=blue]someotherMc[/color]";
       newMovieList[5] = "[color=blue]andAnotherMc[/color]";
       newMovieListCount = 5;
     [color=#000087]function[/color] fader(){
     i = 1;
       [color=#000087] while[/color] (i < movieList.count) {
        fadeOut(movieList*);
       [color=#878787] // add some sort of 1 sec delay here
    [/color]    i++;
        }
       [color=#000087]  while[/color] (j < newMovieListCount){
         fadeIn(newMovieList[j]);
       [color=#878787]  // 1 sec delay
    [/color]     j++;
         }
                            
       [color=#878787]// clear up ready for the next batch
    [/color]                        
        movieList = newMovieList;
        movieListCount = newMovieListCount;
        newMovieList = "";
        newMovieListCount = "";
        } [color=#878787]// end fader
    [/color]    [color=#000087]break[/color];
                    
      } [color=#878787]// end switch;
    [/color]        
    }
    
    
    [color=#000087]on[/color] (release){
            pageControl("[color=blue]homepage[/color]");
    }

Please don’t laugh too hard ! and every little help would be greatly appreciated - thanks!