Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

bad argument #-2 to 'insert' (Proxy expected, got nil)
Started by chodongwon82 Oct 08 2018 01:24 AM

1 reply to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

chodongwon82

[GLOBAL: userInfoPane.html]
chodongwon82
  • Enthusiast

  • 44 posts
  • Corona SDK

local group = display.newGroup( )

local image = display.newRect( 100, 100, 100, 100 )
	group:insert( image )

for i=group.numChildren, 1, -1 do
    display.remove( group[i] )
	group[i] = nil
end

function generate()
	group:insert( image )
end


-- timer.performWithDelay( 1000, generate ) -- bad argument #-2 to 'insert' (Proxy expected, got nil)

generate() -- work well

Can anyone please explain why the "timer.performWithDelay" code is wrong?

How can I insert the image into the group after a time I want?


[TOPIC: post.html]
#2

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,628 posts
  • Corona SDK

You create image, insert it into group, then immediately destroy it as part of the numChildren loop. Image is now pointing to nothing. It is a fluke of timing that it works without the delay, with a delay image is no longer a display object.


[topic_controls]
[/topic_controls]