how to cancel a transition

I got stuck, in one little part of my code.

I looked here

http://docs.coronalabs.com/api/library/transition/index.html

and also here

http://docs.coronalabs.com/api/library/transition/cancel.html

and it gives me this

local tweenReference = transition.to(currentTarget, { time=400, y=upperLimit, transition=easing.outQuad}) -- Later cancel the tween transition.cancel(tweenReference)

I used that in my code

local function doneButton ()         transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1})         done.isVisible = false         audio.stop ()         transition.cancel(greenBar1)         transition.cancel(greenBar2)     end done:addEventListener("tap", doneButton)

because I have this transition

local function smallFrame ()                                 greenBar2.isVisible = false                                 transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1})                                 transition.to(greenBar2, {time=100, x=150, y=580})                             end

It’s just a little green bar, but it does not work.

also in corona docs. says :


Cancels a transition in progress. The object that is being
transitioned will stop in place (rather than reset to the beginning or
end of the transition).

For example, if you were transitioning the alpha of an object from 1.0 to 0 and called transition.cancel()
before the transition completed, the object will be partially
transparent (it will leave the object where it is at the time this
function was called).


But I guess I want to cancel the function, so when I re-do the function again

it will start from the beginning.

Please I need some help here.

Thanks

You write it yourself, but I do not see you storing ‘greenBar1’ and ‘greenBar2’

What I see greenBar2 is object so you cannot cancel it (you wrote yourself one have to cancel some tween reference)

piotrz55…

I believe you want me to think more than I can.

my brain is going as much as possible.

I don’t really get it.

what do you mean by “storing” I think I read that before. but still I don’t understand.

so I just don’t get it.

would you please help me with more details.

You have display object greenBar1, right? And you do transition.to(greenBar1, {}). You cannot do transition.cancel(greenBar1)! You cannot cancel object - you must cancel transition.
You do it like this
[lua]
local tweenReference = transition.to(greenBar1, {})
transition.cancel(tweenReference)
[/lua]

Thanks piotrz55.

I tried 3 ways. No luck!

this is my code. look at the bottom part.

local play1 = audio.loadSound ( "music1.mp3" ) display.setStatusBar( display.HiddenStatusBar ) local background = display.newImage("bg.png") local greenBar1 local greenBar2 local done local centerX = display.contentWidth / 2 local centerY = display.contentHeight / 2 local opX = 240 -- original placed .x local opY = 580 local tx1 = display.newText ("a Text messaging, or texting, is the act of typing and sending a brief, electronic message between two or more mobile phones or fixed or portable devices over a phone network. The term originally referred to messages sent using the Short Message Service (SMS); it has grown to include messages containing image, video, and sound content (known as MMS messages). The sender of a text message is known as a texter, while the se itself has different colloquialisms depending on itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia an itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of d the Philippines, an SMS in most of  the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of rvice itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of mainland Europe, and a TMS or SMS in the Middle East, Africa and Asia.a vea ver si le atinoaa ver si le atino ver si lea ver si le atino atinor se atinoea ver si le ata ver si le atinoino a vea ver si le atinoaa ver si le atino ver si lea ver si le atino atinor si le atinoatino", 30, 20, 450, 400, nil, 18) local song1 = display.newImage("music1.png") song1.x = opX song1.y = opY     local function playSong ()         transition.to(done, {time=200, y=(centerY + 340)})         transition.to(song1, {time=100, x=centerX, y=centerY, xScale=2.5, yScale=2.5})         greenBar1.isVisible = true                 local function secondStaff ()                     greenBar1.isVisible = false                     greenBar2.isVisible = true                     transition.to(greenBar1, {time=100, x=150, y=310})                             local function smallFrame ()                                 greenBar2.isVisible = false                                 transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1})                                 transition.to(greenBar2, {time=100, x=150, y=580})                             end                     transition.to(greenBar2, {time=14800, x=1000, onComplete=smallFrame})                 end         transition.to(greenBar1, {time=14800, x=1000, onComplete=secondStaff})         audio.play(play1)     end song1:addEventListener("tap", playSong) greenBar1 = display.newRect(0, 0, 7, 200) greenBar1:setFillColor(140, 255, 140) greenBar1.x = 150 greenBar1.y = 310 greenBar1.isVisible = false greenBar2 = display.newRect(0, 0, 7, 200) greenBar2:setFillColor(140, 255, 140) greenBar2.x = 150 greenBar2.y = 580 greenBar2.isVisible = false done = display.newImage("manzana.png") done.x = centerX done.y = centerY + 600 done:scale (.5, .5)     local function doneButton ()         local tweenReference = transition.to(greenBar1, {})         transition.to(done, {time=200, y=(centerY + 600)})         transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1})         audio.stop ()         transition.cancel(tweenReference)     end done:addEventListener("tap", doneButton)

I also tried putting the

local tweenReference = transition.to(greenBar1, {})

on top, outside the – doneButton function

and it doesn’t work


I know what you must be thinking.

I need to learn more. I know.

please be patience with me.

thanks for all your help

My transition.to(greenBar1, {}) have nothing in curly brackets just for simplicity to not type everything, don’t take literaly because in this form it does nothing!

local play1 = audio.loadSound ( "music1.mp3" ) display.setStatusBar( display.HiddenStatusBar ) local background = display.newImage("bg.png") local greenBar1 local greenBar2 local done local greenBar1Tween local centerX = display.contentWidth / 2 local centerY = display.contentHeight / 2 local opX = 240 -- original placed .x local opY = 580 local tx1 = display.newText ("a Text messaging, or texting, is the act of typing and sending a brief, electronic message between two or more mobile phones or fixed or portable devices over a phone network. The term originally referred to messages sent using the Short Message Service (SMS); it has grown to include messages containing image, video, and sound content (known as MMS messages). The sender of a text message is known as a texter, while the se itself has different colloquialisms depending on itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia an itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of d the Philippines, an SMS in most of the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of rvice itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of mainland Europe, and a TMS or SMS in the Middle East, Africa and Asia.a vea ver si le atinoaa ver si le atino ver si lea ver si le atino atinor se atinoea ver si le ata ver si le atinoino a vea ver si le atinoaa ver si le atino ver si lea ver si le atino atinor si le atinoatino", 30, 20, 450, 400, nil, 18) local song1 = display.newImage("music1.png") song1.x = opX song1.y = opY local function playSong () transition.to(done, {time=200, y=(centerY + 340)}) transition.to(song1, {time=100, x=centerX, y=centerY, xScale=2.5, yScale=2.5}) greenBar1.isVisible = true local function secondStaff () greenBar1.isVisible = false greenBar2.isVisible = true greenBar1Tween = transition.to(greenBar1, {time=100, x=150, y=310}) local function smallFrame () greenBar2.isVisible = false transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1}) transition.to(greenBar2, {time=100, x=150, y=580}) end transition.to(greenBar2, {time=14800, x=1000, onComplete=smallFrame}) end greenBar1Tween = transition.to(greenBar1, {time=14800, x=1000, onComplete=secondStaff}) audio.play(play1) end song1:addEventListener("tap", playSong) greenBar1 = display.newRect(0, 0, 7, 200) greenBar1:setFillColor(140, 255, 140) greenBar1.x = 150 greenBar1.y = 310 greenBar1.isVisible = false greenBar2 = display.newRect(0, 0, 7, 200) greenBar2:setFillColor(140, 255, 140) greenBar2.x = 150 greenBar2.y = 580 greenBar2.isVisible = false done = display.newImage("manzana.png") done.x = centerX done.y = centerY + 600 done:scale (.5, .5) local function doneButton () transition.to(done, {time=200, y=(centerY + 600)}) transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1}) audio.stop () transition.cancel(greenBar1Tween) end done:addEventListener("tap", doneButton)

Read carefully my changes (mainly where I wrote and used greenBar1Tween)

thank you very much.

I see the little green bar stops now. so the transition is cancelled.

the only problem is that when I tap on the image, the transition(green bar) keeps going

from where it was last stop.

The idea is having like a --reset-- button.

the transition starts on x=1 ---- to x.100

I don’t know where people is going to cancel the transition

let’s say on x.36 —

so the green bar stops moving – isVisible = false – and RESET to x.1

so when the next time they start the transition, the green bar will start from the beginning.


and the other part I don’t understand at all…

in line 46 you say

greenBar1Tween = transition.to(greenBar1, {time=14800, x=1000, onComplete=secondStaff})

and then in line 38 you say

greenBar1Tween = transition.to(greenBar1, {time=100, x=150, y=310})

is the same – greenBar1Tween – variable

is like saying

this = 34

this = 76

isn’t it confusing, the same variable name is equal to two different things

I got it! I got it!!! YES!!!

Where you put the – transition.cancel(greenBar1Tween) – inside the doneButton.

I kept thinking,

"If here you cancel the transition, just make the green bar equal to the starting point.

and then make it invisible."

So I try in different ways – invisible first , the .x = 150 (it didn’t work)

I put it in a different way and it works!!!

local function doneButton ()         transition.to(done, {time=200, y=(centerY + 600)})         transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1})         audio.stop ()         transition.cancel(greenBar1Tween)         greenBar1.x = 150         greenBar1.isVisible = false     end

Now when I stop the green bar, any time…

and I start the music again, the little green bar starts from the beginning…GREAT!!!

thanks for all your help.

I’m really proud of my self, I’m learning, I’m learning…

Programming is all about “what and how to do thinks? - code it later” :stuck_out_tongue: First you must state your problem. Think how you would do it, what you need and then write code :slight_smile:

I thought I got…sad…

something very strange is happening.

I have 2 green bars – one on top, one on the bottom.

----------THIS IS THE FIRST TIME I RUN THE CODE-----------

When I run the code the first time

the TOP green bar moves from x=1 to x=100

at the end

the BOTTOM green bar moves from x=1 to =100


if I cancel the transition on the BOTTOM first…

everything works fine, perfect.

I can reset the music and start all over and no problem

I can do it as many times as I want.


The problem is if I stop the transition on the TOP green bar.

I get a nil value – File: ? in line 75

here is where I have the cancel the BOTTOM green line


I don;t get it.

I changed – greenBar1Tween – for || reset1 || and || reset2 ||

local function doneButton ()         transition.to(done, {time=200, y=(centerY + 600)})         transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1})         audio.stop ()         transition.cancel(reset1)         greenBar1.x = 150         greenBar1.isVisible = false         transition.cancel(reset2)         greenBar2.x = 150         greenBar2.isVisible = false     end

What is happening?

full code please

if not one thing, — it’s another …

you need to have a lot of patience for programming… a lot.

I admired you guys a lot.


I thought I might use an “if – else” statement. There I go.

local function doneButton () &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transition.to(done, {time=200, y=(centerY + 600)}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; audio.stop () &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if greenBar1.x \< 1000 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print ("this is the FIRST time") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.cancel(reset1) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;greenBar1.x = 150 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;greenBar1.isVisible = false &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elseif greenBar2.x \< 1000 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print ("this is the SECOND time") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;greenBar2.isVisible = false &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.cancel(reset2) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;greenBar2.x = 150 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp; end

I try different forms, I think I have the idea…

I even put “print”

but in Terminal I don’t see the SECOND time

I guess it’s not detecting the – elseif ********* then

I don’t know why.

I really need help, I’m very close, but not yet!


sorry I did not see the “Full code please”

here it is.

local play1 = audio.loadSound ( "music1.mp3" ) display.setStatusBar( display.HiddenStatusBar ) local background = display.newImage("bg.png") local greenBar1 local greenBar2 local done local reset1 local reset2 local centerX = display.contentWidth / 2 local centerY = display.contentHeight / 2 local opX = 240 -- original placed .x local opY = 580 local tx1 = display.newText ("a Text messaging, or texting, is the act of typing and sending a brief, electronic message between two or more mobile phones or fixed or portable devices over a phone network. The term originally referred to messages sent using the Short Message Service (SMS); it has grown to include messages containing image, video, and sound content (known as MMS messages). The sender of a text message is known as a texter, while the se itself has different colloquialisms depending on itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia an itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of d the Philippines, an SMS in most of&nbsp; the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of rvice itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of mainland Europe, and a TMS or SMS in the Middle East, Africa and Asia.a vea ver si le atinoaa ver si le atino ver si lea ver si le atino atinor se atinoea ver si le ata ver si le atinoino a vea ver si le atinoaa ver si le atino ver si lea ver si le atino atinor si le atinoatino", 30, 20, 452, 400, nil, 18) local song1 = display.newImage("music1.png") song1.x = opX song1.y = opY &nbsp;&nbsp;&nbsp; local function playSong () &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transition.to(done, {time=200, y=(centerY + 340)}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transition.to(song1, {time=100, x=centerX, y=centerY, xScale=2.5, yScale=2.5}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; greenBar1.isVisible = true &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local function secondStaff () &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; greenBar1.isVisible = false &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; greenBar2.isVisible = true &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reset1 = transition.to(greenBar1, {time=100, x=150, y=310}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local function smallFrame () &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; greenBar2.isVisible = false &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reset2 = transition.to(greenBar2, {time=100, x=150, y=580}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reset2 = transition.to(greenBar2, {time=14800, x=1000, onComplete=smallFrame}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reset1 = transition.to(greenBar1, {time=14800, x=1000, onComplete=secondStaff}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; audio.play(play1) &nbsp;&nbsp;&nbsp; end song1:addEventListener("tap", playSong) greenBar1 = display.newRect(0, 0, 7, 200) greenBar1:setFillColor(140, 255, 140) greenBar1.x = 150 greenBar1.y = 310 greenBar1.isVisible = false greenBar2 = display.newRect(0, 0, 7, 200) greenBar2:setFillColor(140, 255, 140) greenBar2.x = 150 greenBar2.y = 580 greenBar2.isVisible = false done = display.newImage("manzana.png") done.x = centerX done.y = centerY + 600 done:scale (.5, .5) &nbsp;&nbsp;&nbsp; local function doneButton () &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transition.to(done, {time=200, y=(centerY + 600)}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; audio.stop () &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if greenBar1.x \< 1000 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print ("this is the FIRST time") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.cancel(reset1) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;greenBar1.x = 150 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;greenBar1.isVisible = false &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elseif greenBar2.x \< 1000 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print ("this is the SECOND time") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;greenBar2.isVisible = false &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.cancel(reset2) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;greenBar2.x = 150 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp; end done:addEventListener("tap", doneButton)

Thanks

You write it yourself, but I do not see you storing ‘greenBar1’ and ‘greenBar2’

What I see greenBar2 is object so you cannot cancel it (you wrote yourself one have to cancel some tween reference)

piotrz55…

I believe you want me to think more than I can.

my brain is going as much as possible.

I don’t really get it.

what do you mean by “storing” I think I read that before. but still I don’t understand.

so I just don’t get it.

would you please help me with more details.

You have display object greenBar1, right? And you do transition.to(greenBar1, {}). You cannot do transition.cancel(greenBar1)! You cannot cancel object - you must cancel transition.
You do it like this
[lua]
local tweenReference = transition.to(greenBar1, {})
transition.cancel(tweenReference)
[/lua]

Thanks piotrz55.

I tried 3 ways. No luck!

this is my code. look at the bottom part.

local play1 = audio.loadSound ( "music1.mp3" ) display.setStatusBar( display.HiddenStatusBar ) local background = display.newImage("bg.png") local greenBar1 local greenBar2 local done local centerX = display.contentWidth / 2 local centerY = display.contentHeight / 2 local opX = 240 -- original placed .x local opY = 580 local tx1 = display.newText ("a Text messaging, or texting, is the act of typing and sending a brief, electronic message between two or more mobile phones or fixed or portable devices over a phone network. The term originally referred to messages sent using the Short Message Service (SMS); it has grown to include messages containing image, video, and sound content (known as MMS messages). The sender of a text message is known as a texter, while the se itself has different colloquialisms depending on itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia an itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of d the Philippines, an SMS in most of&nbsp; the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of rvice itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of mainland Europe, and a TMS or SMS in the Middle East, Africa and Asia.a vea ver si le atinoaa ver si le atino ver si lea ver si le atino atinor se atinoea ver si le ata ver si le atinoino a vea ver si le atinoaa ver si le atino ver si lea ver si le atino atinor si le atinoatino", 30, 20, 450, 400, nil, 18) local song1 = display.newImage("music1.png") song1.x = opX song1.y = opY &nbsp;&nbsp; &nbsp;local function playSong () &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.to(done, {time=200, y=(centerY + 340)}) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.to(song1, {time=100, x=centerX, y=centerY, xScale=2.5, yScale=2.5}) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;greenBar1.isVisible = true &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local function secondStaff () &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;greenBar1.isVisible = false &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;greenBar2.isVisible = true &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.to(greenBar1, {time=100, x=150, y=310}) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local function smallFrame () &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;greenBar2.isVisible = false &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1}) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.to(greenBar2, {time=100, x=150, y=580}) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.to(greenBar2, {time=14800, x=1000, onComplete=smallFrame}) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.to(greenBar1, {time=14800, x=1000, onComplete=secondStaff}) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;audio.play(play1) &nbsp;&nbsp; &nbsp;end song1:addEventListener("tap", playSong) greenBar1 = display.newRect(0, 0, 7, 200) greenBar1:setFillColor(140, 255, 140) greenBar1.x = 150 greenBar1.y = 310 greenBar1.isVisible = false greenBar2 = display.newRect(0, 0, 7, 200) greenBar2:setFillColor(140, 255, 140) greenBar2.x = 150 greenBar2.y = 580 greenBar2.isVisible = false done = display.newImage("manzana.png") done.x = centerX done.y = centerY + 600 done:scale (.5, .5) &nbsp;&nbsp; &nbsp;local function doneButton () &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local tweenReference = transition.to(greenBar1, {}) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.to(done, {time=200, y=(centerY + 600)}) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1}) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;audio.stop () &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;transition.cancel(tweenReference) &nbsp;&nbsp; &nbsp;end done:addEventListener("tap", doneButton)

I also tried putting the

local tweenReference = transition.to(greenBar1, {})

on top, outside the – doneButton function

and it doesn’t work


I know what you must be thinking.

I need to learn more. I know.

please be patience with me.

thanks for all your help

My transition.to(greenBar1, {}) have nothing in curly brackets just for simplicity to not type everything, don’t take literaly because in this form it does nothing!

local play1 = audio.loadSound ( "music1.mp3" ) display.setStatusBar( display.HiddenStatusBar ) local background = display.newImage("bg.png") local greenBar1 local greenBar2 local done local greenBar1Tween local centerX = display.contentWidth / 2 local centerY = display.contentHeight / 2 local opX = 240 -- original placed .x local opY = 580 local tx1 = display.newText ("a Text messaging, or texting, is the act of typing and sending a brief, electronic message between two or more mobile phones or fixed or portable devices over a phone network. The term originally referred to messages sent using the Short Message Service (SMS); it has grown to include messages containing image, video, and sound content (known as MMS messages). The sender of a text message is known as a texter, while the se itself has different colloquialisms depending on itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia an itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of d the Philippines, an SMS in most of the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of rvice itself has different colloquialisms depending on the region. It may simply be referred to as a text in North America, the United Kingdom, Australia and the Philippines, an SMS in most of mainland Europe, and a TMS or SMS in the Middle East, Africa and Asia.a vea ver si le atinoaa ver si le atino ver si lea ver si le atino atinor se atinoea ver si le ata ver si le atinoino a vea ver si le atinoaa ver si le atino ver si lea ver si le atino atinor si le atinoatino", 30, 20, 450, 400, nil, 18) local song1 = display.newImage("music1.png") song1.x = opX song1.y = opY local function playSong () transition.to(done, {time=200, y=(centerY + 340)}) transition.to(song1, {time=100, x=centerX, y=centerY, xScale=2.5, yScale=2.5}) greenBar1.isVisible = true local function secondStaff () greenBar1.isVisible = false greenBar2.isVisible = true greenBar1Tween = transition.to(greenBar1, {time=100, x=150, y=310}) local function smallFrame () greenBar2.isVisible = false transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1}) transition.to(greenBar2, {time=100, x=150, y=580}) end transition.to(greenBar2, {time=14800, x=1000, onComplete=smallFrame}) end greenBar1Tween = transition.to(greenBar1, {time=14800, x=1000, onComplete=secondStaff}) audio.play(play1) end song1:addEventListener("tap", playSong) greenBar1 = display.newRect(0, 0, 7, 200) greenBar1:setFillColor(140, 255, 140) greenBar1.x = 150 greenBar1.y = 310 greenBar1.isVisible = false greenBar2 = display.newRect(0, 0, 7, 200) greenBar2:setFillColor(140, 255, 140) greenBar2.x = 150 greenBar2.y = 580 greenBar2.isVisible = false done = display.newImage("manzana.png") done.x = centerX done.y = centerY + 600 done:scale (.5, .5) local function doneButton () transition.to(done, {time=200, y=(centerY + 600)}) transition.to(song1, {time=100, x=opX, y=opY, xScale=1, yScale=1}) audio.stop () transition.cancel(greenBar1Tween) end done:addEventListener("tap", doneButton)

Read carefully my changes (mainly where I wrote and used greenBar1Tween)

thank you very much.

I see the little green bar stops now. so the transition is cancelled.

the only problem is that when I tap on the image, the transition(green bar) keeps going

from where it was last stop.

The idea is having like a --reset-- button.

the transition starts on x=1 ---- to x.100

I don’t know where people is going to cancel the transition

let’s say on x.36 —

so the green bar stops moving – isVisible = false – and RESET to x.1

so when the next time they start the transition, the green bar will start from the beginning.


and the other part I don’t understand at all…

in line 46 you say

greenBar1Tween = transition.to(greenBar1, {time=14800, x=1000, onComplete=secondStaff})

and then in line 38 you say

greenBar1Tween = transition.to(greenBar1, {time=100, x=150, y=310})

is the same – greenBar1Tween – variable

is like saying

this = 34

this = 76

isn’t it confusing, the same variable name is equal to two different things