frame:SetAnchor(pointOnFrame, relativeToThisFrame, pointOnThatOtherFrame, offsetX, offsetY)
Offsets increase in a positive direction to the right (for X) and down (for Y). They increase in a negative direction to the left (for X) and up (for Y).
So... If you want to anchor your MyAddonFrame to the main screen (GuiRoot), in the top-left corner, but out from each side about 10 pixels, you'd do this:
Lua Code:
MyAddonFrame:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, 10, 10)
If you want to anchor the left side of your MyAddonFrame2 to the right side of your MyAddonFrame1, you'd do this:
Lua Code:
MyAddonFrame2:SetAnchor(LEFT, MyAddonFrame1, RIGHT, 0, 0)
If you want to make your MyAddonBG texture fill your whole MyAddonFrame (anchoring to all corners), then you can do this:
Lua Code:
MyAddonBG:SetAnchorFill(MyAdonFrame)
One last example: if you want your MyAddonFrame to spread across the bottom of the screen, without having to worry about figuring out how big the users screen is (resolution/width), then you can do this:
Lua Code:
MyAddonFrame:SetAnchor(BOTTOMLEFT, GuiRoot, BOTTOMLEFT, 0, 0)
MyAddonFrame:SetAnchor(BOTTOMRIGHT, GuiRoot, BOTTOMRIGHT, 0, 0)
MyAddonFrame:SetHeight(100)