Stop a function when another function starts?

This is only my second post so I should start by saying I’m a web designer and a noob at programing altogether.

If I touch foo_A, foo_A moves up and foo_B fades in slowly. If I touch Back, foo_A goes back where it started from, and foo_B fades out so all images are back where they started.

I want the moving and fading to top and return to it’s beginning state when Back is touched, even if its touched before all the transitions are completed.

Right now, if I hit Back before foo_B is done fading in, it will continue to fade in and end up not being right.

Does that make sense? [import]uid: 101670 topic_id: 19878 reply_id: 319878[/import]

You’d name the transition something like trans1 then do;

[lua]if trans1 then
transition.cancel(trans1)
–Put in code to reset foo_B alpha and position here
end[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 19878 reply_id: 77210[/import]

Thank you, Peach!

Now - how do I name a transition? I have a function name, and inside that function is a bunch of transitions. I don’t see anything anywhere about naming the transition? [import]uid: 101670 topic_id: 19878 reply_id: 77419[/import]

[lua]local transition1 = transition.to(object,{params})

transition.cancel(transition1)[/lua]

You can also use this for way for naming timer events as well.
Hope this helps! [import]uid: 49520 topic_id: 19878 reply_id: 77422[/import]

Thanks James!

What if I have several transitions happening - can I name them all as a group - or something? [import]uid: 101670 topic_id: 19878 reply_id: 77424[/import]

You encapsulate them in a table using a loop.
[lua]local transitionTable = {}

for i=1, i<10, 1 do
transitionTable[i] = transition.to(object,{})
end[/lua]

Does that work? [import]uid: 49520 topic_id: 19878 reply_id: 77426[/import]

Sorry for being a complete noob…

So if I have a single transition like this:

local huntTitleTrans1 = transition.to( title_huntCountry, { time=1400, x=8, y=50, xScale=.8, yScale=.8 } )

How do I get that transition into the function? This is what it is now:

function moveHunt ( event )
transition.to( title_huntCountry, { time=1400, x=8, y=50, xScale=.8, yScale=.8 } )
end

? [import]uid: 101670 topic_id: 19878 reply_id: 77432[/import]

No worries. We’ve all been there, lol. Declare the variable outside of the function and then assign it during the event later on.

[lua]local huntTitleTrans1
function moveHunt ( event )

huntTitleTrans1 = transition.to( title_huntCountry, { time=1400, x=8, y=50, xScale=.8, yScale=.8 } )

end[/lua]

[import]uid: 49520 topic_id: 19878 reply_id: 77463[/import]

Thanks for your help. I’m still quite confused on some things but I’ve managed to work things around where they are working better! [import]uid: 101670 topic_id: 19878 reply_id: 77579[/import]