fade an image in then out?

Can anyone take a look at this and help me please.

http://pastebin.com/TFpXrBE0

You seem to be missing your alpha=0 or alpha=1 from your transition.to/from?

Thanks, but it still doesn't work?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local function flashWhite ()
                                
                                flash.isVisible = true
                                transition.to( flash, { time=200, alpha = 1, onComplete=listener1 } )
 
                                local listener1 = function( obj )
 
                        transition.from( flash, { time=200,  alpha = 0, onComplete=listener2 } )
 
                    end
 
                    local listener2 = function( obj )
 
                        flash:removeSelf()
 
                    end
                        
                        end
                        
                        flashWhite()

Weird, not sure. Try this, I tested locally and this works:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
local img = display.newImage("flash.png")
 
function img:fade()
        self.alpha = 0
        self.tween = transition.to(self, {time=500, alpha=1, onComplete=img.onFadeIn})
end
 
function img:onFadeIn()
        transition.cancel(self.tween)
        self.tween = transition.to(self, {time=500, alpha=0, onComplete=img.onFadeOut})
end
 
function img:onFadeOut()
        transition.cancel(self.tween)
        self:removeSelf()
end
 
img:fade()
views:1655 update:2011/10/11 8:57:46
corona forums © 2003-2011