2 Replies Latest reply on May 27, 2006 4:11 PM by Newsgroup_User

    Function Problem pt 2

    danny_biy Level 1
      This code lets me click index_mc button and then it plays frame 33 and once that is done on frame 65 it opens index.html.

      _root.index_mc.onPress = function() {
      gotoAndPlay(33)
      }
      _root.onEnterFrame = function(){
      if(this._currentframe == 65){
      getURL("index.html");
      stop();
      delete _root.onEnterFrame;
      }
      }

      However, the problem I have is that I need this code to work for multiple buttons and each button will open a different page once it gets to frame 65, so the next section would look like this:

      _root.but1_mc.onPress = function() {
      gotoAndPlay(33)
      }
      _root.onEnterFrame = function(){
      if(this._currentframe == 65){
      getURL("about me.html");
      stop();
      delete _root.onEnterFrame;
      }
      }

      If I was to use both of these codes it will just open one of the pages everytime, because in the code it says once you get to frame 65 do this, it doesn't say anything about after you click that and then get to frame 65 to differentiate them. I need to use the same code for about 7 buttons just changing the name of the button and the page it opens at the end. If you have a solution, please help. Thank you!
        • 1. Re: Function Problem pt 2
          Level 7
          You can store the URL you want to load for each button in a variable and
          then in each of your button onPress functions, assign it the proper
          string. Then use the variable in your onEnterFrame loop.

          var pageToLoad:String;

          _root.but1_mc.onPress = function() {
          gotoAndPlay(33);
          pageToLoad = "button1_page.html"
          };
          _root.but2_mc.onPress = function() {
          gotoAndPlay(33);
          pageToLoad = "button2_page.html"
          };

          _root.onEnterFrame = function() {
          if (this._currentframe == 65) {
          getURL(pageToLoad);
          stop();
          delete _root.onEnterFrame;
          }
          };

          danny biy wrote:
          > This code lets me click index_mc button and then it plays frame 33 and once
          > that is done on frame 65 it opens index.html.
          >
          > _root.index_mc.onPress = function() {
          > gotoAndPlay(33)
          > }
          > _root.onEnterFrame = function(){
          > if(this._currentframe == 65){
          > getURL("index.html");
          > stop();
          > delete _root.onEnterFrame;
          > }
          > }
          >
          > However, the problem I have is that I need this code to work for multiple
          > buttons and each button will open a different page once it gets to frame 65, so
          > the next section would look like this:
          >
          > _root.but1_mc.onPress = function() {
          > gotoAndPlay(33)
          > }
          > _root.onEnterFrame = function(){
          > if(this._currentframe == 65){
          > getURL("about me.html");
          > stop();
          > delete _root.onEnterFrame;
          > }
          > }
          >
          > If I was to use both of these codes it will just open one of the pages
          > everytime, because in the code it says once you get to frame 65 do this, it
          > doesn't say anything about after you click that and then get to frame 65 to
          > differentiate them. I need to use the same code for about 7 buttons just
          > changing the name of the button and the page it opens at the end. If you have
          > a solution, please help. Thank you!
          >
          • 2. Re: Function Problem pt 2
            Juankpro Level 2
            _root.but1_mc.onPress = function() {
            gotoPage("about me.html");
            };
            function gotoPage(page) {
            gotoAndPlay(33);
            _root.onEnterFrame = function() {
            if (this._currentframe == 65) {
            getURL(page);
            stop();
            delete _root.onEnterFrame;
            }
            };
            }