buttons vs fields vs images best practice?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

buttons vs fields vs images best practice?

Post by FireWorx » Thu Mar 15, 2012 2:18 am

Hi, I just cloned a field 160 times to use in a project. The fields are kept invisible and when called on via a nested repeat loop are placed edge to edge top to bottom in a grid. The grid size varies but should never get larger than 40 over and 40 across. There size is adjusted and then they are made visible. I also created 160 transparent buttons to be placed and centers over the fields.as labels. They are also kept invisible until needed and then placed in the repeat loop and made visible.

My question is this. When I created the buttons it took probably 5 times longer to clone them. (about 4 or 5 minutes) This is a1 time set up feature only in development BUT I could probably use graphics or fields as the labels rather than buttons.

What is the least CPU intensive and best practice?

Dave

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: buttons vs fields vs images best practice?

Post by dunbarx » Thu Mar 15, 2012 4:25 am

I wonder what kind of gadget you have made.

I was not sure about the details in your post, so I took the liberty making one field, and doing this:

Code: Select all

on mouseUp
   put the loc of fld 1 into tLoc
   lock screen
   repeat with u = 1 to 40
      repeat with y = 1 to 40
         clone fld 1
         set the loc of the last field to item 1 of tLoc + u & "," & item 2 of tLoc + y
      end repeat
   end repeat
end mouseUp
This gave me 1601 fields in a very tight grid. Took about one second. Again,though still intrigued by what you are doing, could the "lock screen" be the key to your problem?

Craig Newman

Craig Newman

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: buttons vs fields vs images best practice?

Post by FourthWorld » Thu Mar 15, 2012 6:04 am

Adding "lock messages" should give you an additional speed boost.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: buttons vs fields vs images best practice?

Post by FireWorx » Thu Mar 22, 2012 5:56 pm

Hi,
Map stuff. I am building apha numeric grids. Based on 7 dynamic inputs. entered below as an example
The size of overall rect of the grid
Columns across = 20
Rows Down = 8
Alpha start top left = A
Number Start top left = 29
Alpha runs = across (which means numbers run down)

Then through division and repeat loops build the grid by resizing, relocating, hiding, and showing fields. (like tiles) It is only done to set up the grid and then a snapshot is taken of the grid so performance is not an on-going issue. The fields are built and named sequentialy ahead of time and are invisible and are called by the repeat loop which has to analyze the desired grid output size and the 7 inputs before it can do its thing.

Dave

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: buttons vs fields vs images best practice?

Post by mwieder » Thu Mar 22, 2012 6:06 pm

What's your repeat loop look like?

You'll get *much* better speed from a "repeat for each" construct than a "repeat with" construct, as in orders of magnitude faster.

Q: Why not just create a card with a 40x40 grid of fields/buttons ahead of time and then just display the ones you need?

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: buttons vs fields vs images best practice?

Post by FireWorx » Thu Mar 22, 2012 9:30 pm

Thanks mark,
Thats exactly what I did although 40 x 40 became a bit overpopulating. What I settled on for ipad was 20 across 30 down. Thanks for the advise on the repeat loop. I have always used the snot out of the repeat with x = 1 to whatever. I think what was taking so long was I was naming each file to say "column && x && Row && y" as I was doing the cloning. I was also messing with the script and by that time most likely I had mucho controls on the card. At this point I think I'm all good to go. If will post the code snipet later when I get on my Mac.
Thanks
Dave

Post Reply