Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How to take a .txt from an url and show it on gideros player — Gideros Forum

How to take a .txt from an url and show it on gideros player

ashlyn_scottashlyn_scott Member
edited August 2012 in General questions
I found a code which take a picture from an url and show it on gideros player.That is :
 
local loader = UrlLoader.new("<a href="http://upload.wikimedia.org/wikipedia/commons/7/7a/Basketball.png&quot" rel="nofollow">http://upload.wikimedia.org/wikipedia/commons/7/7a/Basketball.png&quot</a><img class="emoji" src="http://forum.gideros.rocks/resources/emoji/wink.png" title=";)" alt=";)" height="20" />
-- <a href="http://tuxpaint.org/stamps/stamps/animals/birds/adelaide-rosella.png" rel="nofollow">http://tuxpaint.org/stamps/stamps/animals/birds/adelaide-rosella.png</a>
local function onComplete(event)
    local out = io.open("|D|image.png", "wb")
    out:write(event.data)
    out:close()
 
    local b = Bitmap.new(Texture.new("|D|image.png"))
    stage:addChild(b)
end
 
local function onError()
    print("error")
end
 
local function onProgress(event)
    print("progress: " .. event.bytesLoaded .. " of " .. event.bytesTotal)
end
 
loader:addEventListener(Event.COMPLETE, onComplete)
loader:addEventListener(Event.ERROR, onError)
loader:addEventListener(Event.PROGRESS, onProgress)
But now, i want not to take a photo, but to take the words which exist on a page. I want to show it on gideros player.For example this url : http://www.pvv.org/~olafb/hysyslib/hysyslib/example.txt
How to do it?
Thanks.

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited August 2012
    local loader = UrlLoader.new("<a href="http://www.pvv.org/~olafb/hysyslib/hysyslib/example.txt&quot" rel="nofollow">http://www.pvv.org/~olafb/hysyslib/hysyslib/example.txt&quot</a><img class="emoji" src="http://forum.gideros.rocks/resources/emoji/wink.png" title=";)" alt=";)" height="20" />
    local function onComplete(event)
        --event.data contains the text
        print(event.data)
    end
     
    local function onError()
        print("error")
    end
     
    local function onProgress(event)
        print("progress: " .. event.bytesLoaded .. " of " .. event.bytesTotal)
    end
     
    loader:addEventListener(Event.COMPLETE, onComplete)
    loader:addEventListener(Event.ERROR, onError)
    loader:addEventListener(Event.PROGRESS, onProgress)
Sign In or Register to comment.