2 Replies Latest reply on Sep 26, 2006 5:52 AM by e_tienne

    dynamic modification of a property list

    e_tienne
      Hi
      I have a property list like this
      mypropList=[#prop1:[val1],#prop2:[#c:[#d:val3]],#prop3:[#e:val4,#f:val5]]

      I would like to modify the properties with dynamic property naming. So I write this :
      propNum=2
      myProp=symbol("prop"&string(propNum)) -- ie #prop2
      mypropList.myProp=newValue

      Director returns an error message -- property not found
      I can do it with
      setProp (mypropList,myProp,newValue)
      but I would like to keep the pointed syntax... I have a very complicated list and the classic syntax is a mess...

      is there a way to do it with pointed syntax ?
      TIA
        • 1. Re: dynamic modification of a property list
          Level 7
          your method assumes that the property in the list is called myProp (or
          #myProp is using the old verbose syntax) but it's just a variable that
          contains the actual name. You won't be able to use the syntax as you would
          like but the next best thing would be to use

          myPropList [myProp] = newValue

          The nice thing about this method is that you don't need to initialize the
          property in the list first.

          Also, make sure myPropList is a property list first but since you identified
          the list in your posting I'm assuming it is valid and that the handler has
          access to it, i.e., it is a global variable or a property of a behavior,
          etc.

          --
          Craig Wollman
          Word of Mouth Productions

          phone 212 928 9581
          fax 212 928 9582
          159-00 Riverside Drive West #5H-70
          NY, NY 10032
          www.wordofmouthpros.com


          "e_tienne" <webforumsuser@macromedia.com> wrote in message
          news:efat30$rte$1@forums.macromedia.com...
          > Hi
          > I have a property list like this
          > mypropList=[#prop1:[val1],#prop2:[#c:[#d:val3]],#prop3:[#e:val4,#f:val5]]
          >
          > I would like to modify the properties with dynamic property naming. So I
          > write
          > this :
          > propNum=2
          > myProp=symbol("prop"&string(propNum)) -- ie #prop2
          > mypropList.myProp=newValue
          >
          > Director returns an error message -- property not found
          > I can do it with
          > setProp (mypropList,myProp,newValue)
          > but I would like to keep the pointed syntax... I have a very complicated
          > list
          > and the classic syntax is a mess...
          >
          > is there a way to do it with pointed syntax ?
          > TIA
          >


          • 2. Re: dynamic modification of a property list
            e_tienne Level 1
            Thanks very much, it works great !!!