Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua 加载远程映像后向侦听器添加ID_Lua_Listener_Coronasdk - Fatal编程技术网

Lua 加载远程映像后向侦听器添加ID

Lua 加载远程映像后向侦听器添加ID,lua,listener,coronasdk,Lua,Listener,Coronasdk,我有一个用于加载远程图像的侦听器,但我需要能够将ID号传递给该侦听器,并且我不确定如何执行该操作。我检索远程映像的代码是: display.loadRemoteImage("http://www.newyorker.com/online/blogs/photobooth/NASAEarth-01.jpg", "GET", networkListener, "banner.png",system.TemporaryDirectory, (globalData.contentX * rows2)

我有一个用于加载远程图像的侦听器,但我需要能够将ID号传递给该侦听器,并且我不确定如何执行该操作。我检索远程映像的代码是:

display.loadRemoteImage("http://www.newyorker.com/online/blogs/photobooth/NASAEarth-01.jpg", "GET", networkListener, "banner.png",system.TemporaryDirectory,  (globalData.contentX * rows2) + globalData.contentX/2, 20 + (i - 1) % 6 * 140
我的听众是:

local function networkListener( event )
    if ( event.isError ) then
        print ( "Network error - download failed" )
    else
        local target = event.target
        target.alpha = 0
        transition.to( target, { alpha = 1.0 } )
        target.width = 590
        target.height = 110 
        target:addEventListener( "touch", target )
        scrollView:insert(target) 
        function target:touch(event)
            if event.phase == "began" then
                display.getCurrentStage():setFocus( self )
                self.isFocus = true

            elseif self.isFocus then
                if event.phase == "moved" then
                    numMoved = numMoved + 1
                    if(numMoved > 10) then
                        display.getCurrentStage():setFocus( nil )
                        self.isFocus = false
                        scrollView:takeFocus( event )
                    end
                elseif event.phase == "ended" or event.phase == "cancelled" then
                    globalData.selectedLocationID = target.id --This needs to be the ID that I pass to this listener
                    if(globalData.approvedToggle == 1) then
                        storyboard.gotoScene("businessScene")
                    else
                        storyboard.gotoScene("locationScene")
                    end
                    display.getCurrentStage():setFocus( nil )
                    self.isFocus = false
                end
            end
        return true
    end
end

在此问题上的任何帮助都将不胜感激,谢谢

不久前,我在制作的一个电子商务应用程序上做了这个。我不熟悉故事板,但我确实记得使用过这个API。如果我没记错的话,您需要使用event.target作为事件侦听器,并在那里传递所有内容。我还记得,您可以在display.loadRemoteImage API中嵌入一个函数,如下所示:

itemImage = display.loadRemoteImage(itemData.imageURL, "GET", 
            function(event)
               event.target.xScale = 0.4
               event.target.yScale = 0.4
               function openSite(event)
                   if event.phase == "ended" then
                      system.openURL( itemData.itemURL )
                   end
               end 
               event.target:addEventListener( "tap", openSite )
            end)
我的建议是删除所有的故事板内容,并尝试使API在不同的文档中工作。我认为你需要简化它,这样你就不会感到困惑

希望这能有所帮助