3 Replies Latest reply on Jun 19, 2007 4:37 PM by Newsgroup_User

    is a 'global' onEnterFrame event possible?

    Angyl
      I have some text that I want to stay in a certain position relative to another item on the stage at ALL times, even when other events are moving that item around.

      Rather than moving the text around in the code whenever I move this item, is it possible to set the coords of the text to ALWAYS be relative to the item, even if it is moved, throughout the entire movie?

      I thought setting up an
      onEnterFrame myTxt._y = itemLoc + 25;

      event at the beginning of my movie, but Flash doesn't like that much...
        • 1. Re: is a 'global' onEnterFrame event possible?
          Level 7
          Angyl,

          > I have some text that I want to stay in a certain position
          > relative to another item on the stage at ALL times, even
          > when other events are moving that item around.

          You can use an onEnterFrame event for that ... in fact, you could wrap
          that text field in a movie clip symbol and let that symbol generate its own
          onEnterFrame event. All you need to do, really, is set the text field's
          position relative to the other item's position.

          > Rather than moving the text around in the code whenever
          > I move this item, is it possible to set the coords of the text
          > to ALWAYS be relative to the item, even if it is moved,
          > throughout the entire movie?

          You could put that text field inside the other item. That would do it.
          Make it a child of that other item's timeline.

          > I thought setting up an
          > onEnterFrame myTxt._y = itemLoc + 25;

          That's the way to go about it; otherwise, you'd need to have the item
          itself move the text field, along with whatever code moves the item.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: is a 'global' onEnterFrame event possible?
            Angyl Level 1
            The reason why I don't put the text in the moving mc itself is because there are LOTS of instances of this mc on the stage. If I put a text field in it they'll all have it.

            I think you're right, unfortunately, in that I"m going to have to have the code that moves the MC also move the individual text as well. Kind of a pain and making my code so much larger but I don't see another way.
            • 3. Re: is a 'global' onEnterFrame event possible?
              Level 7
              Angyl,

              > The reason why I don't put the text in the moving mc itself
              > is because there are LOTS of instances of this mc on the stage.

              Aha. Yeah, that makes sense, then.

              > I think you're right, unfortunately, in that I"m going to have to
              > have the code that moves the MC also move the individual
              > text as well.

              Off hand, that's the only way I see to do it. Unless ... well, you
              could wrap them both in a movie clip. That way, your item could exist on
              its own in as many instances as you please -- but this one instance would be
              locked in-step with your text. Of course, you'd have to re-route your
              ActionScript to move animate new movie clip instead of that particular
              instance of the item.

              > Kind of a pain and making my code so much larger but I don't
              > see another way.

              It's not so much larger, is it? Just set up a loop that positions the
              text's _x and _y in relation to the item's.


              David Stiller
              Adobe Community Expert
              Dev blog, http://www.quip.net/blog/
              "Luck is the residue of good design."