Can't forward reference anymore

Just recently switched back to Director 1.4 and for some odd reason
i cant forward reference anything anymore O.o any ideas?

can u provide some sample code??

Forward referencing problem

Here is a sample of what I am experiencing.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 
new = function ( params )
 
        local localGroup = display.newGroup()
        
        local bg
        local tapevent  
        
        bg = display.newImage("bg.png", true)
        bg.xScale = .58 bg.yScale = .58
        bg.x = display.contentWidth / 2 bg.y = display.contentHeight / 2
        localGroup:insert(bg)
        
        bg:addEventListener( "tap", tapevent )
        
        function tapevent( event )
        
                print( "touched" )
                
        end
 
 
return localGroup
 
end

HOOOK! my bad, i understand what i did wrong now, mistake on my part.

If anyone else has issues forward referencing listener functions check to make sure they're called AFTER being declared in a function. Forgot the code has to run through it all first. Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
        local localGroup = display.newGroup()
        local group = display.newGroup()
 
        local bg
        local touch
        local go
        
        localGroup:insert( group )
        
        -------------------------------------
 
        -------------------------------------
        
        function go()
 
                bg = display.newImage("bg.png", true)
                bg.xScale = .58 bg.yScale = .58
                bg.x = display.contentWidth / 2 bg.y = display.contentHeight / 2
                bg:addEventListener( "tap", touch )
                group:insert(bg)        
 
        end
        
        function touch( event )
        
                print( "touched" )
                
        end
        
        go()
views:1502 update:2012/1/1 13:29:50
corona forums © 2003-2011