recursive transitions?

Why does this fail?
I love the transition library (over event based animation) but really miss some of the extra Flash style tweening library parameters like “repeat” and “yoyo” to create scrolling backgrounds, glowing lights, or any repeating movements. It seems I should be able to use the onComplete but can’t get it to work. Something about tail calls?

--trying to get a display object to fly across the screen repeatedly   
local function = loopingAnimation (target)  
 myArt.x=0  
 transition.to (myArt, {time=2000, x=500, onComplete=loopingAnimation})  
end  
  

[import]uid: 5339 topic_id: 3504 reply_id: 303504[/import]

i’d do it like this so that it’s a re-usable function. note I had to define one of my function variables in advance because they call each other, but Lua seems to read linearly so loopingAnimation won’t know what loopingAnimationComplete is otherwise since it’s defined below it (or vice versa)

[lua]local loopingAnimationComplete

local loopingAnimation = function(target)
target.x=0
transition.to(target, {time=2000, x=320, onComplete=loopingAnimationComplete})
end

loopingAnimationComplete = function(event)
print(“complete”)
loopingAnimation(event)
end
ball2.y=50
ball2.y=150

loopingAnimation(ball1)
loopingAnimation(ball2)[/lua]

not sure if it’s the best way but it works

j [import]uid: 6645 topic_id: 3504 reply_id: 10541[/import]

this way also works, but note the “complete” functionis global, which may not be ideal

[lua]local function loopingAnimation(target)
target.x=0
transition.to(target, {time=2000, x=320, onComplete=loopingAnimationComplete})
end

function loopingAnimationComplete(event)
print(“complete”)
loopingAnimation(event)
end[/lua] [import]uid: 6645 topic_id: 3504 reply_id: 10543[/import]

Brilliant! Thanks, so much! Making the code reusable is a huge help too. [import]uid: 5339 topic_id: 3504 reply_id: 10550[/import]

@andyhullinger, can you give us examples of other parameters that you’d find useful? [import]uid: 26 topic_id: 3504 reply_id: 11469[/import]

http://developer.anscamobile.com/forum/2010/09/10/adding-features-transition-api

Walter, Thanks for your interest.

I posted this a while ago but that was during the crush to get the SDK out and I know you guys were crazy busy. In a nutshell, I think all of us coming from Flash development would benefit from parity with “industry standard” Flash tweening libraries like TweenLite/Max

Some of the things I mention in the post are new (repeat, repeatDelay, yoyo) some are simply adding convenience to the syntax of your existing API (onStartAt, etc…)

I rely on TweenLiteMax for nearly everything (tweening volume, tweening “frames” within traditional clips, etc…)

-Andy [import]uid: 5339 topic_id: 3504 reply_id: 11498[/import]

Hi Andy, a couple of your requests were actually implemented.

We do have an “onStart” listener which can either be a function or a table listener (if you want to attach parameters to it; see http://developer.anscamobile.com/content/events-and-listeners).

We also have “transition.from” http://developer.anscamobile.com/reference/index/transitionfrom which is essentially what startAt: does.

Are there other params in TweenLite/Max along the lines of (repeat, repeatDelay, yoyo) that are super useful?
[import]uid: 26 topic_id: 3504 reply_id: 11536[/import]

Walter,

A similar core would be great!! http://www.greensock.com/as/docs/tween/com/greensock/core/TweenCore.html

I find that whenever I choose to use the transition API’s it’s a sort of “style” of coding and I like to stay in the rhythm of it’s syntax instead of mixing in “enterFrame listeners” or “timer.performWithDelay”. When you guys are ready to expose OpenGL blur, shadow, glow, and various blend modes your transition library will be a great syntax for making it easy to work with those features.
I also make frequent use of these features…

2.)“allTo” (targets:Array, duration:Number, vars:Object, stagger:Number = 0, onCompleteAll:Function = null, onCompleteAllParams:Array = null) Tween multiple objects to the same end values.

a.) “allFrom” Exactly the same as TweenMax.allTo(), but instead of tweening the properties from where they’re at currently to whatever you define, this tweens them the opposite way - from where you define TO where ever they are when the tweens begin

b.) “allFromTo” Tweens multiple targets from a common set of starting values to a common set of ending values; exactly the same as TweenMax.allTo(), but adds the ability to define the starting values.

3.) “delayedCall” - handy syntax, as a companion to “timer.performWithDelay” but for the transition API?

4.) “frame” Tweens a MovieClip (or spritesheet) to a particular frame number.

5.) “volume” Tweens the volume of an object with a soundTransform property (MovieClip/SoundChannel/NetStream, etc.).

[import]uid: 5339 topic_id: 3504 reply_id: 11573[/import]

http://www.greensock.com/as/docs/tween/com/greensock/TimelineLite.html

If we’re talking a Christmas wishlist? I’d LOVE! TimelineLite/Max functionality! ;^)
-Andy [import]uid: 5339 topic_id: 3504 reply_id: 11574[/import]