It looks like you're new here. If you want to get involved, click one of these buttons!
results = Core.class(Sprite) function results:init(params) local screen = Bitmap.new(Texture.new("resources/images/opt_back.png")) self:addChild(screen) screen:setPosition(0,0) p = 2 local a = 1 mySize = table.getn(params) k=1 tit = "" q = "" function onComplete2(p, event) q = event.data the[p] = TextField.new(nil, "hello") the[p]:setPosition(100,50 +a*50) the[p]:setTextColor(0x007B25) the[p]:setScaleX(3)the[p]:setScaleY(3) ------------------------------------------ if ( tit == "xx") then local picLoader = UrlLoader.new("<a href="http://localhost/bird.png"" rel="nofollow">http://localhost/bird.png"</a><img class="emoji" src="http://forum.gideros.rocks/resources/emoji/wink.png" title=";)" alt=";)" height="20" /> local function onComplete3(event) local out = io.open("|D|image.png", "wb") out:write(event.data) out:close() local b = Bitmap.new(Texture.new("|D|image.png")) b:setPosition(10,10) stage:addChild(b) -----HERE IS NOT OKAY.PNG FILE DOESN'T LOAD end picLoader:addEventListener(Event.COMPLETE, onComplete3) picLoader:addEventListener(Event.ERROR, onError) picLoader:addEventListener(Event.PROGRESS, onProgress) --------------------------------------------------------------- end the[p]:setText(params[p+1] .. q) print("q : " .. q) stage:addChild(the[p]) -- HERE IS OKAY a = a + 1 end while(k < mySize+1) do if (params[k] ==true) then p=k local loader2 = UrlLoader.new(params[k+2]) loader2:addEventListener(Event.COMPLETE, onComplete2, p) end k = k+3 end end |
Comments
Remember K.I.S.S.
Likes: loves_oi
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
If i don't not use nested functions , what else can i do to perform it? Any idea?
Thanks a lot
Move ALL of your onComplete functions OUTSIDE of (preferably before) the :init function and make them local like so
You can then freely (and safely) access any variables defined in results:init() and you can be sure your looking at the correct instance.
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
local picLoader = UrlLoader.new(URL)
although i send two different values of URL , it will load the same URL for them.
But when i select two checkbox ,
Moskow MoskowPicture
Madrid MadridPicture
in screen , it will look like as:
Moskow MoskowPicture
Madrid MoskowPicture
in screen.
When i run the same code without changing anything ,it may look like :
Moskow MadridPicture
Madrid MadridPicture
However , in all attempts , the right url of the Moskow and Madrid comes .
This is the code:
URL is :http://localhost/moscow.png
URL is :http://localhost/madrid.png
However , in all attempts , when i checked moscow and madrid ,
in screen , it will look like as:
Moskow MoskowPicture
Madrid MoskowPicture
When i run the same code without changing anything ,it may look like :
Moskow MadridPicture
Madrid MadridPicture
There's also some things, I'm not sure why you would do the way you're doing and I wonder if maybe you should look over some general Lua material (I've used http://www.lua.org/pil/index.html quite a bit). I'm rather new to some of this myself and I realize there can be a lot to take in.
It's really hard to narrow down what's going on with what you've provided and some examples of what I feel like might be oddities are:
For instance your comment here:
---This line works wrongly. It doesn't load the second URL. It loads the same photo although this line works two times and values of tit are different.
Your 'the' table will have a lot of random holes because it looks like the parameter your passing is every 3rd parameter, but you're using the index from the params to pass into your 'the' table. (ie: you will have values at the[1], the[4] etc.)
Likes: techdojo