Page 1 of 1

Script works in Rev 2.6 but not in 3.5

Posted: Thu Jul 23, 2009 9:43 am
by Dixie
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.

Posted: Thu Jul 23, 2009 11:17 am
by Mark
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

Posted: Sat Jul 25, 2009 8:38 am
by Dixie
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

Posted: Sat Jul 25, 2009 9:30 am
by Mark
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