object.parent

Description:

A read-only property that returns the object's parent.

Syntax:
Example:

local group = display.newGroup()
 
local rect = display.newRect(100, 100, 50, 50)
rect:setFillColor(170, 170, 170)
group:insert(rect)
 
rect.parent:remove(rect)  --removes rect from group

Returns:
Remarks:
Supported on operating systems and platforms for build numbers shown:
  • Mac OS X:
    Corona SDK 1.0
  • Windows:
    Corona SDK 2.0
  • iOS:
    Corona SDK 1.0
  • Android:
    Corona SDK 2.0

Replies

dgaedcke
User offline. Last seen 1 day 21 hours ago. Offline
Joined: 17 Apr 2010

unless I'm mistaken, this comment is wrong:

--removes rect from group

it should remove the whole "group" from the stage

Tom
User offline. Last seen 28 min ago. Offline
Staff
Joined: 13 Jul 2010

This example does remove rect from the group, named "group".

The stage is also a group (the main one), which contains the group named "group".

dgaedcke
User offline. Last seen 1 day 21 hours ago. Offline
Joined: 17 Apr 2010

oh yeah, I mis-read it....I was thinking it was removeSelf() on the parent (ie group) and thus was removing the whole hierarchy...rather than just the rect.

Sorry for the false alarm...