No, setting obj to nil will not nil the glow variable. What will nil the glow variable is the function where glow is declared local being exited…
A variable is nil when it does not exist (by virtue of not being declared.)
All variables declared local will effectively cease to exist when their parent function exits because they cannot be seen outside of their scope.
[lua]function makeGlow()
local glow = display.newImage(“red heart glow.png”) – goes nil when makeGlow exits
local function goAway(obj) – obj goes nil when goAway exits
display.remove(obj) – remove tells corona to remove the obj display object from the display groups
end – the obj variable stops being visible and effectively ceases to exist
transition.to ( glow, { time=1000, alpha=0, onComplete=goAway} )
end[/lua]
One important thing to know is that setting ‘obj’ to nil inside the goAway function will not affect the ‘glow’ variable. They are two different variables. Yes, they refer to the same object in memory, but they are not the same value. Killing one of them does not affect the other.
For more on that, lookup Object Oriented Programming and maybe take a look at some beginners tutorials on Java and C# “pointers and references”. [import]uid: 8271 topic_id: 34810 reply_id: 138448[/import]