2 Replies Latest reply on Mar 3, 2007 3:44 PM by laconicSF

    Reverse Referral from a SpriteNum to it's Object

    laconicSF
      Hello,

      I've created an object called "myObject" using the new() command and attached it to a parent script ("Object Parent"). It was then added to the actorList, so it would be "actorList[1]," for instance. There is also "actorList[2], actorList[3]...." in the list.

      In the "Object Parent" script, I've defined two properties:

      1) a "spriteNum" property to connect actorList[1] to a particular sprite in a channel ("actorList[1].spriteNum")

      2) a "state" property with the state being "on" or "off". ("actorlist[1].state")

      Each object in the actorList (i.e. "actorList[2], actorList[3]....") has it's own .spriteNum and .state property.

      What I'd like to do is be able to click the sprite in the channel that is associated with actorList[1] and change the "state" property to "on" or "off".

      My Question:
      How do I get the sprite in a channel that is "actorList[1].spriteNum" to refer to object "actorList[1]," so I can change it's property? I can't figure out a syntax for refering an object from it's property, which is the reverse of the usual.

      Any help would be appreciated!

      T
        • 1. Re: Reverse Referral from a SpriteNum to it's Object
          James Newton, ACP Level 3
          This sounds unstable and difficult to maintain. If your script instances refer to particular sprites, what advantage does your system have over attaching a behavior to each sprite?

          The principle purpose of the actorList is to send a #stepFrame event to each instance it contains, once per frame. Does your system use #stepFrame? If not, then there are better solutions to using the actorList. If your system does use #stepFrame, then there may be good reasons to use #enterFrame instead, as this improves performance; in which case also there are better solutions than using the actorList.

          If you describe what you are trying to achieve, rather than how you are currently trying to achieve it, we may be able to provide you with a simpler solution.
          • 2. Re: Reverse Referral from a SpriteNum to it's Object
            laconicSF Level 1
            Hello,

            Thanks. I'll look back at how to explain and re-ask...