13 Replies Latest reply on Jun 10, 2006 8:58 AM by Newsgroup_User

    _global locator not working

    Edward Bull
      Hi there i am making a website with about eight pages, all the buttons are on the main page, I have the pages tweening in, when the user clicks a button i would like these pages to tween back out then bring the new page in. I think you do this by using the global locator syntax. I have been using instances for my buttons, the following script is on frame 60

      stop();
      _global.locator;
      contact_BT.onRelease = function() {
      play();
      _global.locator = "contact";
      };

      Could anyone tell me this same script but so it can go on the button rather than instance names as it is not working at all. Cheers. Ed
        • 1. Re: _global locator not working
          Level 7
          Ed,

          Let's step through your code.

          > stop();

          This simply stops the timeline on whatever frame holds this code.

          > _global.locator;

          This references a property of the _global object called locator. This
          line doesn't really do anything, because locator isn't assigned a value.
          You could lose this line withuot any issues, but it's not harming anything.

          > contact_BT.onRelease = function() {

          This line assigns a function to the Button.onRelease event of a
          particular button instance -- the instance with the instance name
          contact_BT.

          > play();

          This line invokes the play() function, which starts the timeline that
          holds this button.

          > _global.locator = "contact";

          This line sets the value of a property in the _global object to the
          string "contact".

          > };

          > Could anyone tell me this same script but so
          > it can go on the button rather than instance
          > names as it is not working at all.

          What isn't working? All you've done at this point is set a property of
          an object (happens to be the _global object, which is accessible to any
          timeline). Earlier, you mentioned this ...

          > i would like these pages to tween back out then
          > bring the new page in. I think you do this by using
          > the global locator syntax

          ... which confuses me a bit. For example, Flash doesn't have "pages," so
          I'm not sure what you mean by that (maybe movie clips? sections of
          timeline?). The _global object itself is just another object, except that
          it's scoped in a special way so that it's "visible" to any timeline, no
          matter the hierarchy. There is no native locator property of the _global
          object. It's as if you're creating an arbitrary variable, basically -- a
          variable named locator -- which on its own doesn't do anything more (at this
          point) than store the string "contact".

          If you test your SWF in the Debugger panel, you'll see that string value
          in the _global.locator property as soon as you click your button.


          David
          stiller (at) quip (dot) net
          Dev essays: http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: _global locator not working
            Edward Bull Level 1
            Yeah sorry i phrased my question wrong, i would like it to move to another section of the timeline labeled "contact" but playing the tween out before it goes there, am i making any sense? Basically my friend has done a similar thing that i would like to achieve and given me his code, i understand now that the locator part has just been named that by him. Can you help me, all i need is the timeline to play the animation then jump to another frame. Cheers.
            • 3. Re: _global locator not working
              Level 7
              Ed,

              > i would like it to move to another section of
              > the timeline labeled "contact" but playing the
              > tween out before it goes there, am i making
              > any sense?

              Sure. The most basic way to go to a label in any timeline is to use the
              gotoAndPlay() function (or its MovieClip.gotoAndPlay() cousin). You could
              have your button simply invoke a play() function, as it's doing now, then
              put another keyframe in your scripts layer several frames later. In *that*
              keyframe, put gotoAndPlay("contact").

              Does that make sense?


              David
              stiller (at) quip (dot) net
              Dev essays: http://www.quip.net/blog/
              "Luck is the residue of good design."


              • 4. Re: _global locator not working
                Edward Bull Level 1
                I understand, however its me, i have not really explained myself very well, i have about eight buttons on my home page when you press these i would like the frame its currently on to tween out then the new graphics to tween in. If i used play() and had another keyframe with script telling it to go to another frame, all my buttons would go to the same frame. The efffect im trying to create is on www.bloq.co.uk, i think this will explain what im trying to do more than i can. thank you for your help with this David i really appreciate it. Ed
                • 5. Re: _global locator not working
                  Level 7
                  Ed,

                  > If i used play() and had another keyframe with
                  > script telling it to go to another frame, all my
                  > buttons would go to the same frame.

                  Aha. That would probably explain why your friend mentioned the _global
                  object, then. If a globally accessible variable exists, you can use it to
                  store the desired frame label for each button. You don't really need the
                  _global object for this, as it turns out.

                  I could see something along these lines (code in a scripts layer of the
                  main timeline) ...

                  // initialize the variable to a blank string
                  var locator:String = "";

                  // stop the timeline
                  stop();

                  // code your buttons to set a particular
                  // value to the variable, then resume the
                  // timeline
                  btnA.onRelease = function() {
                  locator = "apples";
                  play();
                  }
                  btnA.onRelease = function() {
                  locator = "oranges";
                  play();
                  }

                  // as the timeline resumes, your tweens
                  // do their thing; finally, they hit a frame
                  // script that tells the playhead to jump
                  // to whatever frame label you desire
                  gotoAndPlay(locator);

                  The value of locator will be whatever each button sets it to be. Each
                  span of timeline can use the same tween (or different tweens) that lead to
                  the same (or different) frame scripts. In any case, the gotoAndPlay()
                  function will send the playhead off to whatever label is recorded in the
                  variable -- the variable "lives" throughout the course of the timeline it's
                  in.

                  Clear as mud? If you still need help, don't hesitate to write back.
                  I'll be out of town tomorrow during the day, but I'll keep an eye on this
                  thread and get back to it as soon as I can.


                  David
                  stiller (at) quip (dot) net
                  Dev essays: http://www.quip.net/blog/
                  "Luck is the residue of good design."


                  • 6. Re: _global locator not working
                    Edward Bull Level 1
                    Hi David i have been battling with it, no joy. I know your code is right however every time i test the movie, when i click "contact" button nothing happens. I have triple checked the instance names are spelt right, i really don't know whats going on. I feel as though i could throw my computer out the window. Do you have any thoughts of why it isnt working? Im pretty sure its me being thick, bet their is something i havnt done. Thanks again. Ed.
                    • 7. Re: _global locator not working
                      LSNsaltlamp Level 1
                      Edward, I found it easier to create a sample file than to try and explain my method. You can download the file from
                      http://www.genesisdigitalsolutions.com/fla/tween.fla

                      I hope it helps.
                      • 8. Re: _global locator not working
                        Level 7
                        Ed,

                        See if LSNsaltlamp's sample file makes sense to you. If not, I'd be
                        willing to look at your own FLA to see what's going on. You could either
                        post it to this forum or email it to me.


                        David
                        stiller (at) quip (dot) net
                        Dev essays: http://www.quip.net/blog/
                        "Luck is the residue of good design."


                        • 9. Re: _global locator not working
                          Edward Bull Level 1
                          Hi david, couldnt open the tween fla, not sure why, i am currently sending you my fla file via e mail. is the address stiller@quip.net ? Thanks again.
                          • 10. Re: _global locator not working
                            Level 7
                            Ed,

                            > Hi david, couldnt open the tween fla, not sure why, i am
                            > currently sending you my fla file via e mail.

                            Okay.

                            > is the address [address withheld] ? Thanks again.

                            Heh ... there's a reason I sort of "hide" my address in the format
                            "stiller (at) quip (dot) net": the idea is to make it readable by humans
                            but not readable by computers. I'm not sure how valid a technique it
                            actually is, but ehh, worth a shot. So I will neither confirm nor deny that
                            the email address you posted is mine. But I will say that I received a FLA
                            from you. ;)

                            I'm unusually busy for some personal and some business reasons this
                            weekend, but I'll get back to you as soon as I can.


                            David
                            stiller (at) quip (dot) net
                            Dev essays: http://www.quip.net/blog/
                            "Luck is the residue of good design."


                            • 11. Re: _global locator not working
                              Level 7
                              >> See if LSNsaltlamp's sample file makes sense to you.
                              >> If not, I'd be willing to look at your own FLA to see
                              >> what's going on. You could either post it to this forum
                              >> or email it to me.

                              Ed,

                              Make sure all your instance names match up. ;) I changed your file, so
                              now I don't remember what you originally had ... but your button instance
                              names were home_BT in one place and home_btn in another, same for the
                              contact button.

                              Look carefully at the code and your button instance names and see how
                              they now match.


                              David
                              stiller (at) quip (dot) net
                              Dev essays: http://www.quip.net/blog/
                              "Luck is the residue of good design."


                              • 12. Re: _global locator not working
                                Edward Bull Level 1
                                Hi david you didnt re send your ammended version, i had a look at the instance names this morning but cant see where they change. Am i looking in the wrong place, this is probably why i have been getting it completely wrong. Thanks for looking at my file. Ed
                                • 13. Re: _global locator not working
                                  Level 7
                                  Ed,

                                  > Hi david you didnt re send your ammended version, i
                                  > had a look at the instance names this morning but cant
                                  > see where they change.

                                  Woops! Sorry, Ed. I resent just now.


                                  David
                                  stiller (at) quip (dot) net
                                  Dev essays: http://www.quip.net/blog/
                                  "Luck is the residue of good design."