Hi All,

I'm making a silly little animate function for my app.

Let's say I have a grc "new".  I'd like to be able to animate it like this:

animate (the long name of grc "new", "loc 100,50;width 40%;height 50%;foregroundColor 255,0,0",200)

How do I pass the name of a custom property, and then use it in a statement?

So, the intent of the function should be pretty clear:
Assuming n frames per second, we have nf = n*200/1000 frames to play with.
Each attribute should change 1/nf between the start value and the end value.

I'm making this up as I go, but something like the code below. Can anyone point out how to dereference the name of a custom property just after the asterisks?

-- pAtts and pTime is only passed the first time
on animate pObj,pAtts,pTime
  if the animating of pObj is false then
    -- set up animating
    -- make sure we always get at least 1 frame
    put max(n*pTime/1000,1) into nf

    split pAtts by ";" and space
    set the pAtts of pObj to pAtts
    repeat for each line aKey in the keys of pAtts
      -- this next line is where I'm stuck...how do I use
      -- the value of 'aKey' as the name of the custom prop
      -- instead of setting the custom prop name to be "aKey_delta"
      -- below? *******************************
      set the aKey&"_delta" of pObj to (<cur>-<new>)/nf
      set the timeslice of pObj to 1/nf
      set the numberOfFrames of pObj to nf
      set the curFrame of pObj to 1
    end repeat
    set the animating of pObj to true
    send "animate "&pObj to me in 1/nf milliseconds
  else
    -- we're animating, so the delta's should exist
    if the curFrame of pObj < the numberOfFrames of pObj then
      set the curFrame of pObj to (the curFrame of pObj + 1)
      put the pAtts of pObj into pAtts
      repeat for each line of the keys of pAtts
        -- do the math to modify the attributes by deltas
      end repeat
      send "animate "&pObj to me in 1/nf milliseconds
    end if
  end if
end animate

Thanks!

-Ken

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to