Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Strange Random bug in my code — Gideros Forum

Strange Random bug in my code

CyberienceCyberience Member
edited March 2013 in Bugs and issues
Here is my issue, I have an event that is on a sprite and when I click it, it sets the clicked sprite to the front, as I read before, you just need to addChild again and it will be at the front, but if I keep clicking this I get the attempt to index a nil value error.

if self then self:getParent():addChild(self) end

includes/menu.lua:239: attempt to index a nil value

it is inside a mouseDown event.
Anything I can look for to help?
REAL programmers type copy con filename.exe
---------------------------------------

Comments

  • BJGBJG Member
    edited March 2013 Accepted Answer
    Perhaps it's attempting to execute "self:getParent():addChild(self)" at a point when self has no parent. You could test for that by adding eg:
    if not self:getParent() then print("Warning - no parent") end
  • CyberienceCyberience Member
    edited March 2013
    thanks!!
    I found the Culprit it seems, I mis understand the aaEventListerner.
    I use the parent for the base, and then the child in the paramter, by changing the base to the child, fixed the problem.
    container.sprite:addEventListener(Event.MOUSE_DOWN, onMenuAvatarMouseDown, touch[row].sprite)
    Change to
    touch[row].sprite:addEventListener(Event.MOUSE_DOWN, onMenuAvatarMouseDown, touch[row].sprite)
    Can anyone explain this to me. the guide is a bit vague in reasoning.
    yep pasted wrong.....
    REAL programmers type copy con filename.exe
    ---------------------------------------
  • BJGBJG Member
    edited March 2013
    container.sprite:addEventListener(Event.MOUSE_DOWN, onMenuAvatarMouseDown, touc[row].sprite)
    Change to
    container.sprite:addEventListener(Event.MOUSE_DOWN, onMenuAvatarMouseDown, touc[row].sprite)
    These are identical...
Sign In or Register to comment.