deletion while moving...

Malte Brill malte.brill at t-online.de
Fri Dec 19 09:56:18 CST 2003


Hi Igor and all,

have you considered changing from move to setting the loc and send in time
yet?

I created a teststack. 2 Buttons:

Btn 1 script:

global flag,direction
on mouseUp
  if there is no btn "animbut" then
    create btn "animbut"
    set the loc of btn "animbut" to the loc of this card
  end if
  --Just to make sure there is a btn that moves
  if the startLoc of btn "animBut" is empty then
    set the startloc of btn "animbut" to the loc of btn "animBut"
  end if
  --Get starting coordinates
  put flag *-1 into flag
  if flag=empty then put 1 into flag
  --you can start/stop animation by clicking this button
  myMove
end mouseUp
on myMove
  lock screen
  --where am I? 
  put item 1 of the loc of btn "animBut"+direction into theX
  put item 2 of the loc of btn "animBut" into theY
  --where shall I move?
  if theX=item 1 of the startLoc of btn "animbut" then
    put 1 into direction
  end if
  if theX=item 1 of the startLoc of btn "animbut"+300 then
    put -1 into direction
  end if
  --new Location
  set the loc of btn "animBut" to theX,theY
  unlock screen
  --call me again
  if flag=1 then send myMove to me in 50 milliseconds
  --50 Milliseconds because we move only 1 pixel each call
  --300/15 seconds=20 pixel each second
  --=1 pixel every 50 milliseconds
end myMove

The second button is the delete button:

global flag
on mouseUp
 put -1 into flag
  --stop moving
 wait 100 milliseconds with messages
 --wait for pending myMove messages
 delete btn "animBut"
end mouseUp

Regards,

Malte



More information about the use-livecode mailing list