Script works in Rev 2.6 but not in 3.5

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Script works in Rev 2.6 but not in 3.5

Post by Dixie » Thu Jul 23, 2009 9:43 am

Good morning... (Well, it is here.)

I have a stack that contains one image...the code below is in the card script.

In Rev 2.6, this works a treat, the image moves smoothly in the stack window. Unfortunately, in Rev 3.5 it only seems to update after the mouse has been released. Movements are very jerky to say the least...

Code: Select all

local startClick,imageRect,imageW,imageH,cardW,cardH

on mouseDown
  if the clickLoc is mouseLoc() then
    put the clickLoc into startClick
    put the the rectangle of image "picView" into imageRect
    put the width of image "picView" into imageW
    put the height of image "picView" into imageH
    put the width of this card into cardW
    put the height of this card into cardH
    movePic
  end if
end mouseDown

on movePic
  repeat until the mouse is up
    put (item 1 of imageRect + (item 1 of mouseLoc() - item 1 of startClick)) into HorzDiff
    put (item 2 of imageRect + (item 2 of mouseLoc() - item 2 of startClick)) into VertDiff
    
    if HorzDiff >= 0 then put 0 into HorzDiff 
    if VertDiff >= 0 then put 0 into VertDiff
    if HorzDiff <= (- imageW) - (- cardW) then put (- imageW) - (- cardW) into HorzDiff
    if VertDiff <= (- imageH) - (- cardH) then put (- imageH) - (- cardH) into VertDiff
    
    set the topleft of image "picView" to HorzDiff,VertDiff
    put the rectangle of image "picView" into imageRect
  end repeat
end movePic
Does anyone know how to get this working again? I have tried until I started getting a little more than grumpy with myself... So, when all else fails, post an SOS to the forum.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Jul 23, 2009 11:17 am

Dear Dixie,

The problem is probably solved, if you change your repeat loop as follows:

Code: Select all

repeat until the mouse is up with messages
 -- your code
  wait 0 millisecs with messages
end repeat
Let me know if this doesn't solve it.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Post by Dixie » Sat Jul 25, 2009 8:38 am

Mark...

Your solution fixed the probem... It has raised more questions though than it has answered, the main one being Why? that after finding references to 'with messages' in the dictionary

regards

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Jul 25, 2009 9:30 am

Dear Dixie,

I believe it was at 2.7 when the graphics engine in Revolution was enhanced. It runs faster now, but as a result it takes more processing power. Sometimes, there isn't enough processing power to redraw the card that quickly. By adding "with messages", you give Revolution time to redraw the card.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply