Navigation menu

WoW:API CreateFrame: Difference between revisions

Jump to navigation Jump to search
233 bytes removed ,  14 December 2009
m
→‎Notes: stray comma
No edit summary
m (→‎Notes: stray comma)
Line 20: Line 20:
Result: displays the horde and alliance insignias in the middle of the screen.
Result: displays the horde and alliance insignias in the middle of the screen.
  local f = CreateFrame("Frame",nil,UIParent)
  local f = CreateFrame("Frame",nil,UIParent)
  [[API Frame SetFrameStrata|f:SetFrameStrata]]("BACKGROUND")
  f:SetFrameStrata("BACKGROUND")
  [[API Region SetWidth|f:SetWidth]](128) -- Set these to whatever height/width is needed  
  f:SetWidth(128) -- Set these to whatever height/width is needed  
  [[API Region SetHeight|f:SetHeight]](64) -- for your Texture
  f:SetHeight(64) -- for your Texture
   
   
  local t = [[API Frame CreateTexture|f:CreateTexture]](nil,"BACKGROUND")
  local t = f:CreateTexture(nil,"BACKGROUND")
  [[API Texture SetTexture|t:SetTexture]]("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Factions.blp")
  t:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Factions.blp")
  [[API Region SetAllPoints|t:SetAllPoints]](f)
  t:SetAllPoints(f)
  f.texture = t
  f.texture = t
   
   
  [[API Region SetPoint|f:SetPoint]]("CENTER",0,0)
  f:SetPoint("CENTER",0,0)
  [[API Region Show|f:Show]]()
  f:Show()


== Notes ==
== Notes ==
Line 43: Line 43:
** Creating frames on the fly for occasions when you don't know how many frames will be needed.
** Creating frames on the fly for occasions when you don't know how many frames will be needed.
** Creating infrequently used frames "on demand", for example: config dialogs, raid frames.
** Creating infrequently used frames "on demand", for example: config dialogs, raid frames.
* Never forget to unset the frames parent, if you want to get rid of a frame. I would suggest to hide the frame via frame:[[API_Region_Hide|Hide]]() and to use frame:[[API_Region_SetParent|SetParent]](nil) afterwards (this will remove the frame from its parents child list). If you just hide the frame without this additional step, the frame will keep alive. If you add a new frame, it will get a higher [[FrameLevel|framelevel]] then the hidden one. After a while you will get frames at maximum [[FrameLevel|framelevel]] which are likely to be drawn in a distorted way (false order caused by equal [[FrameLevel|framelevel]]).
* Never forget to unset the frames parent, if you want to get rid of a frame. I would suggest to hide the frame via frame:[[API_Region_Hide|Hide]]() and to use frame:[[API_Region_SetParent|SetParent]](nil) afterwards (this will remove the frame from its parents child list). If you just hide the frame without this additional step, frames created afterwards will get a higher [[FrameLevel|framelevel]] then the hidden one. After a while you will get frames at maximum [[FrameLevel|framelevel]] which are likely to be drawn in a distorted way (false order caused by equal [[FrameLevel|framelevel]]).