Hi,
i was trying to implement image resizing with direction in the following blog
http://coronalabs.com/blog/2014/06/10/tutorial-fitting-images-to-a-size/#comment-98422
it works fine with me using local images but i was not able to do it with remote images :
here is the code i am testing
[lua]
local function fitImage( displayObject, fitWidth, fitHeight, enlarge )
–
– first determine which edge is out of bounds
–
local scaleFactor = fitHeight / displayObject.height
local newWidth = displayObject.width * scaleFactor
if newWidth > fitWidth then
scaleFactor = fitWidth / displayObject.width
end
if not enlarge and scaleFactor > 1 then
return
end
displayObject:scale( scaleFactor, scaleFactor )
end
local function networkListener( event )
if ( event.isError ) then
print ( “Network error - download failed” )
else
event.target.alpha = 0
transition.to( event.target, { alpha = 1.0 } )
end
print ( "event.response.fullPath: ", event.response.fullPath )
print ( "event.response.filename: ", event.response.filename )
print ( "event.response.baseDirectory: ", event.response.baseDirectory )
end
local horse = display.loadRemoteImage( “http://omanevents.net/OmanEventsApp/oeImages/horse.png”, “GET”, networkListener, “horseCopy.png”, system.TemporaryDirectory)
fitImage( horse, 50, 50, false )
[/lua]
any idea why the code is not working. i am getting this error :
File: main.lua
Line: 10
Attempt to index local ‘displayObject’ (a nil value)
stack traceback:
main.lua:10: in function ‘fitImage’
main.lua:50: in main chunk
Regards
Abdul