3 Replies Latest reply on Jun 23, 2006 3:28 AM by Newsgroup_User

    Getting function to execute at the startup of movie (function is inside a child movie)

    complexity Level 1
      Hi all,
      I have a small menu with 5 options, I am trying to have 1 turned on (blinking) when my movie first runs.
      I am calling the function but nothing happens. However if I run over the option (which is using the same function) the option becomes selected, so I cant figure out how to or where to call the function from to get it to work.

      The option menu is controlled via a function called menuchange();

      function menuchange() {
      switch(_root.menuvar){
      case "1":
      //its settings settings
      break;
      case "2":
      //its settings settings
      break;
      case "3":
      //its settings settings
      break;
      case "4":
      //its settings settings
      break;
      case "5":
      //its settings settings
      break;

      Now the menuvar variable is holding the correct value I need eg. 1 and I am executing the function like:

      _root.menuvar = "1"; // makeing sure there is a varialbe in there
      //then executing the menuchange function call like
      _root.pt_menu.ptmenumc.menufinal.menuchange(); //execute the function to turn the corresponding menu option on!

      I am calling this a few times in the first frames of the movie, but I still get no turned on state on my menu!

      My file is here:
      http://users.ncable.net.au/~timfrancis/final_function_call.fla

      If someone could show me how I can get this function to work and get one of the menu options to be in an on state when the movie runs would be much appreciated.

        • 1. Re: Getting function to execute at the startup of movie (function is inside a child movie)
          Level 7
          Hi!

          This is probably a timing issue. Make sure the function exists before you
          call it, and make sure that the instance of the movieclips that you want to
          perform some action on has been created before you try to do something to
          them. You can verify if this is the problem with
          trace(myFunction);
          before you call myFunction
          and
          trace(myInstanceOfMenuOrWhatever);
          before you try to do something to myInstanceOfMenuOrWhatever. If you get
          undefined on any of them, then this is the problem.

          Adding a preloader to the movie should solve the problem. You can find some
          tutorials on this at:
          http://www.gotoandlearn.com/
          (Check out both basic flash preloader and advanced flash preloader).

          Cheers!

          /Jensen/



          "complexity" <webforumsuser@macromedia.com> wrote in message
          news:e7fulj$174$1@forums.macromedia.com...
          > Hi all,
          > I have a small menu with 5 options, I am trying to have 1 turned on
          > (blinking)
          > when my movie first runs.
          > I am calling the function but nothing happens. However if I run over the
          > option (which is using the same function) the option becomes selected, so
          > I
          > cant figure out how to or where to call the function from to get it to
          > work.
          >
          > The option menu is controlled via a function called menuchange();
          >
          > function menuchange() {
          > switch(_root.menuvar){
          > case "1":
          > //its settings settings
          > break;
          > case "2":
          > //its settings settings
          > break;
          > case "3":
          > //its settings settings
          > break;
          > case "4":
          > //its settings settings
          > break;
          > case "5":
          > //its settings settings
          > break;
          >
          > Now the menuvar variable is holding the correct value I need eg. 1 and I
          > am
          > executing the function like:
          >
          > _root.menuvar = "1"; // makeing sure there is a varialbe in there
          > //then executing the menuchange function call like
          > _root.pt_menu.ptmenumc.menufinal.menuchange(); //execute the function to
          > turn
          > the corresponding menu option on!
          >
          > I am calling this a few times in the first frames of the movie, but I
          > still
          > get no turned on state on my menu!
          >
          > My file is here:
          > http://users.ncable.net.au/~timfrancis/final_function_call.fla
          >
          > If someone could show me how I can get this function to work and get one
          > of
          > the menu options to be in an on state when the movie runs would be much
          > appreciated.
          >
          >
          >


          • 2. Re: Getting function to execute at the startup of movie (function is inside a child movie)
            complexity Level 1
            Hi Jensen yes it already has a preloader, take a look at the file if you get a chance.

            http://users.ncable.net.au/~timfrancis/final_function_call.fla

            I am calling the function quite a few times.
            • 3. Re: Getting function to execute at the startup of movie (function is inside a child movie)
              Level 7
              Hi again!

              Your code is rather messy, making it hard to debug and hard to update. You
              should strive to gather all your code in one layer and one frame.

              Anyway, if I understand your problem correctly, then menuchange() has
              nothing to do with the visual effect you get on the menu element
              (flimmering, etc). That effect is triggered by this code:
              this.gotoAndStop("paused");
              which can be fined inside the button on the onRollOver = function()
              definition.

              You also seem to have some stuff in your code/file which is not being used
              at all. Like all the extra frames in those buttons. And in final_pt_menu you
              have two frame, which could easily be reduced to one, as the second frame
              only holds a code:
              gotoAndPlay(1);

              which is not needed as flash will be looping back to 1 anyways.

              /Jensen/

              "complexity" <webforumsuser@macromedia.com> wrote in message
              news:e7g8i5$db7$1@forums.macromedia.com...
              > Hi Jensen yes it already has a preloader, take a look at the file if you
              > get a chance.
              >
              > http://users.ncable.net.au/~timfrancis/final_function_call.fla
              >
              > I am calling the function quite a few times.