Accessing custom props using array notation
devin_asay at byu.edu
Thu Aug 19 10:48:17 CDT 2010
On Aug 19, 2010, at 4:43 AM, Chipp Walters wrote:
> Put the custom prop into an array var, then you can access the contents.
> put the uMyArray of btn "test" into tArray
> put tArray["prop1"] into tVar
Thanks Chipp. That works if the custom prop is an array to start with, but my question is whether it is possible to access all kinds of custom property data in the default custom property set using array notation. Here's the situation:
I have an image object that has several different visual states. The state is represented by image data stored in custom properties of the image, labeled like this:
When I want to change visual states I simply set the image text to one of the custom properties. It would be much easier to do if I could do something like this:
set the text of img "myImg" to the customKeys["state" & currStateNum] of img "myImg"
Instead, I have to construct clumsy "do" statements to make the changes.
Unfortunately this doesn't work when using properties in the default set. It does work when you have created the properties in your own sets:
set the text of img "myImg" to the myPropSet["state" & currStateNum] of img "myImg"
(From memory, so I may be missing a detail of the syntax.)
So the question is, can you access non-array data in custom props using array syntax when using just the default property set?
> On Wednesday, August 18, 2010, Devin Asay <devin_asay at byu.edu> wrote:
>> Anyone know if it's possible to access custom properties from an objects default custom property set using array notation? This is easy to do for custom property sets you create yourself.
>> set the myPropSet["prop1"] of btn "myBtn" to "foo" -- works
>> But I can't figure out if you can do the same thing with the default set:
>> put the customKeys["prop1"] of img "myImg" into "bar" -- doesn't work
>> If this could be done it would be nice for constructing custom property names dynamically when access custom props, as in a sequence of prop names like prop1, prop2, prop3, etc.
Humanities Technology and Research Support Center
Brigham Young University
More information about the use-livecode