ButtonMaker
04-05-2009, 02:56 AM
there is a problem with my code but i couldnt find it !!! i have 2 buttons "previous" and "next" for tree object;
previous button code :
nCount = Tree.GetChildCount("Tree1", "0");
if (nCount > 0) then
Tree.SetSelectedNode("Tree1", tostring(nInd));
MediaPlayer.Load("media1", Tree.GetNode("Tree1", nInd).Data);
if (nInd == nCount) then
nInd = 1;
else
nInd = nInd - 1;
end
end
next button code :
nCount = Tree.GetChildCount("Tree1", "0");
if (nCount > 0) then
Tree.SetSelectedNode("Tree1", tostring(nInd));
MediaPlayer.Load("media1", Tree.GetNode("Tree1", nInd).Data);
if (nInd == nCount) then
nInd = 1;
else
nInd = nInd + 1;
end
end
when i click next button it works ok and jumps the next node but once if i click the previous button it jumps to first node not the one before selected and then next button gives the same error !!!
previous button code :
nCount = Tree.GetChildCount("Tree1", "0");
if (nCount > 0) then
Tree.SetSelectedNode("Tree1", tostring(nInd));
MediaPlayer.Load("media1", Tree.GetNode("Tree1", nInd).Data);
if (nInd == nCount) then
nInd = 1;
else
nInd = nInd - 1;
end
end
next button code :
nCount = Tree.GetChildCount("Tree1", "0");
if (nCount > 0) then
Tree.SetSelectedNode("Tree1", tostring(nInd));
MediaPlayer.Load("media1", Tree.GetNode("Tree1", nInd).Data);
if (nInd == nCount) then
nInd = 1;
else
nInd = nInd + 1;
end
end
when i click next button it works ok and jumps the next node but once if i click the previous button it jumps to first node not the one before selected and then next button gives the same error !!!