WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Problem with ScrollFrame (https://www.wowinterface.com/forums/showthread.php?t=2614)

TryToMod 12-10-05 10:24 AM

Problem with ScrollFrame
 
Hey.

I've got a very annoying problem..
Have tried to make a scrollbar/frame for a few days now... I can create the scrollframe, but not that it scroll data :(

I got 1 error
Code:

interface\AddOns\scrollFrame\scrollFrame.lua:17 attempt to index a nil value
Ok! - Something is wrong at line 17 in .lua.. That is
Code:

getglobal("MyModEntry"..line.."_Text"):SetText(MyModData[lineplusoffset]);
I've tried to move frames, etc, etc but nothing works :(

This is how the code looks like:

scrollFrame.lua
Code:

function MyMod_OnLoad()
  MyModData = {};
  for i=1,50 do
    MyModData[i] = "Test "..math.random(100);
  end
 end


function MyModScrollBar_Update()

  local line; -- 1 through 5 of our window to scroll
  local lineplusoffset; -- an index into our data calculated from the scroll offset
  FauxScrollFrame_Update(MyModScrollBar,50,5,16);
  for line=1,5 do
    lineplusoffset = line + FauxScrollFrame_GetOffset(MyModScrollBar);
    if lineplusoffset < 50 then
      getglobal("MyModEntry"..line.."_Text"):SetText(MyModData[lineplusoffset]);
      getglobal("MyModEntry"..line):Show();
    else
      getglobal("MyModEntry"..line):Hide();
    end
  end
 end

scrollFrame.xml
Code:

<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
C:\Projects\WoW\Bin\Interface\FrameXML\UI.xsd">
        <Script file="scrollFrame.lua"/>
<Frame name="scrollbar" toplevel="true" parent="UIParent" frameStrata="DIALOG"
    hidden="false" enableMouse="true">

        <Size><AbsDimension x="300" y="600"/></Size>
        <Anchors><Anchor point="CENTER"/></Anchors>

<Frames>
<ScrollFrame name="MyModScrollBar" inherits="FauxScrollFrameTemplate">
  <Size>
    <AbsDimension x="30" y="80"/>
  </Size>
  <Anchors>
    <Anchor point="TOPRIGHT"/>
  </Anchors>
  <Scripts>
    <OnVerticalScroll>
      FauxScrollFrame_OnVerticalScroll(16, MyModScrollBar_Update);
    </OnVerticalScroll>
  </Scripts>
 </ScrollFrame>


 <Button name = "MyModEntryTemplate" virtual="true">
  <Size>
    <AbsDimension x="150" y="16" />
  </Size>
  <Layers>
    <Layer level="BORDER">
      <FontString name="$parent_Text" inherits="GameFontHighlight" wraponspaces="false"
              justifyH="LEFT" text="MyModEntry"/>
    </Layer>
  </Layers>
 </Button>
</Frames>

<Frames>
 <Button name="MyModEntry1" inherits="MyModEntryTemplate" text="Test">
  <Anchors>
    <Anchor point="TOPRIGHT" relativeTo="MyModScrollBar" relativePoint="TOPLEFT"/>
  </Anchors>
 </Button>
 <Button name="MyModEntry2" inherits="MyModEntryTemplate">
  <Anchors>
    <Anchor point="TOPLEFT" relativeTo="MyModEntry1" relativePoint="BOTTOMLEFT"/>
  </Anchors>
 </Button>
 <Button name="MyModEntry3" inherits="MyModEntryTemplate">
  <Anchors>
    <Anchor point="TOPLEFT" relativeTo="MyModEntry2" relativePoint="BOTTOMLEFT"/>
  </Anchors>
 </Button>
 <Button name="MyModEntry4" inherits="MyModEntryTemplate">
  <Anchors>
    <Anchor point="TOPLEFT" relativeTo="MyModEntry3" relativePoint="BOTTOMLEFT"/>
  </Anchors>
 </Button>
 <Button name="MyModEntry5" inherits="MyModEntryTemplate">
  <Anchors>
    <Anchor point="TOPLEFT" relativeTo="MyModEntry4" relativePoint="BOTTOMLEFT"/>
  </Anchors>
 </Button>


</Frames>
</Frame>

<Frame name="OnLoad">
        <Scripts>
                <OnLoad>
                        MyMod_OnLoad();
                </OnLoad>
        </Scripts>
</Frame>

</Ui>

Please, I need help.. Im going nuts here :)


All times are GMT -6. The time now is 09:57 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI