When using Actors, you can use self:GetParent()
and self:GetChild()
to get elements from other ActorFrames or Actors.
self:GetChild()
can only be used by ActorFrames.
You can think of an ActorFrame as a tree of objects. This is the original table. And now you've called GetParent on the ActorProxy.
Def.ActorFrame{
Def.BitmapText{ Name="MyText" },
* Def.ActorProxy{
OnCommand=function(self)
self:GetParent()
end
},
}
When calling it, you go back up a level, which in this case, it will become ActorFrame.
In this new location, we get the MyText
actor, which can be achieved by calling the GetChild command, and can also return back to the ActorFrame, as we're now in a level that can get both actors (shown in orange).
Def.ActorFrame{
* Def.BitmapText{ Name="MyText" },
Def.ActorProxy{
OnCommand=function(self)
self:GetParent():GetChild("MyText"):spin()
end
},
}
The command uses a String argument, but can also grab from nested tables in case of an ActorFrame not having actors with names assigned. On those cases, actors are just indexed on that ActorFrame set.
Def.ActorFrame{
OnCommand=function(self)
-- If we want to get to the BitmapText, we'll need to get
-- the second entry on the ActorFrame.
self:GetChild("")[2] -- returns the BitmapText actor.
end,
Def.Sprite{},
Def.BitmapText{}
}
Def.ActorFrame{
OnCommand=function(self)
-- If we want to get to the BitmapText,
-- we'll need to get the "Text" actor.
self:GetChild("Text") -- returns the BitmapText actor.
end,
Def.Sprite{ Name = "Image" },
Def.BitmapText{ Name = "Text" }
}