Parallel activities
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Parallel activities
Dears all,
I am new to this list as well as to RR and the first think I try, when looking to a new language, is to develop an introduction to the application where my logo is bouncing into the screen. I used the nice Bouncy.rev example, to start, just changing the "dropme" handler so to never stop the bouncing and introducing the reflection movement.
Easy and nice to do it but, due to the process always staying into the "dropme" handler I cannot manage the "escapekey" handler to stop the bouncyng when I push the Eascape Key (of course!), so to pass to further stack.
Can You help to understand how to do to have it working?
Very best wishes from,
Carmine
I am new to this list as well as to RR and the first think I try, when looking to a new language, is to develop an introduction to the application where my logo is bouncing into the screen. I used the nice Bouncy.rev example, to start, just changing the "dropme" handler so to never stop the bouncing and introducing the reflection movement.
Easy and nice to do it but, due to the process always staying into the "dropme" handler I cannot manage the "escapekey" handler to stop the bouncyng when I push the Eascape Key (of course!), so to pass to further stack.
Can You help to understand how to do to have it working?
Very best wishes from,
Carmine
You could just insert the following line somewhere in your handler: "wait for 5 milliseconds with messages". This should permit other handlers to start while just creating a small lag in the bouncing animation.
Or a more fancy way of controlling a looping handler would be like this:
Or a more fancy way of controlling a looping handler would be like this:
Code: Select all
on stopAnimateLogo
 cancel the animateLogoMsgID of me
end stopAnimateLogo
on animateLogo
 -- Do one step of bouncing logo
 send "animateLogo" to me in 3 ticks
 set the animateLogoMsgID of me to the result
end animateLogo
Parallel activities +
Dear xApple,
thank You for Your nice answer.
1. I tried the line statement "wait for 5 milliseconds with messages" into the handler but it was not stopping!
How can I check why?
2. I will try to implement the fancy code You suggeste. If it is not too work for You, can You explain it or send where to read the related documentation reference?
Thank You very much,
Carmine
thank You for Your nice answer.
1. I tried the line statement "wait for 5 milliseconds with messages" into the handler but it was not stopping!
How can I check why?
2. I will try to implement the fancy code You suggeste. If it is not too work for You, can You explain it or send where to read the related documentation reference?
Thank You very much,
Carmine
Hi Carmine and xApple,
Using a flag is more secure.
Best,
Mark
Using a flag is more secure.
Code: Select all
local lStopFlag
on rawKeyUp theKey
if theKey is 65307 then
put true into lStopFlag
else
pass rawKeyUp
end if
end rawKeyUp
on animateLogo
-- Do one step of bouncing logo
if lStopFlag is false then
send "animateLogo" to me in 3 ticks
end if
end animateLogo
on startAnimateLogo
put false into lStopFlag
animateLogo
end startAnimateLogo
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Parallel activities +1
Very thanks to everybody for the suggestion!
But (still and always recurring, my "but") is there any who may drive me to understand the concepts who stay on the back of all this trying?
1. Why "wait for 5 milliseconds with messages" into the handler should work and why it is not working? Where can I find documentation (and study it, so to avoid to make complex questions about this!)?
2. Looking at the code, my suspect is that the Escape is expected only at the start, while I would always have the Escape push, able to stop the bouncing and go on with the real code. In the form of a starting signature of the application I will develop.
Again, and more then before, my thanks and best wishes for the support,
Carmine
But (still and always recurring, my "but") is there any who may drive me to understand the concepts who stay on the back of all this trying?
1. Why "wait for 5 milliseconds with messages" into the handler should work and why it is not working? Where can I find documentation (and study it, so to avoid to make complex questions about this!)?
2. Looking at the code, my suspect is that the Escape is expected only at the start, while I would always have the Escape push, able to stop the bouncing and go on with the real code. In the form of a starting signature of the application I will develop.
Again, and more then before, my thanks and best wishes for the support,
Carmine
Dear Carmine,
1. Wait for 5 milliseconds will not work in this case.
2. Just give it a try and let me know if it doesn't work.
Best,
Mark
1. Wait for 5 milliseconds will not work in this case.
2. Just give it a try and let me know if it doesn't work.
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Parallel activities +2
Dear Mark,
here is all the card script:
======================================
local tDragging -- true if dragging the window, false if not
local dx,dy -- the current x and y movement variable
local sx,sy -- the current x and y coordinates of the stack
local cx,cy -- the location at which the user clicked in the stack to start dragging
local sx0,sy0 -- when slingshotting, the start x and y
local stepx, stepy, inWindow
local tMessage -- the id of the message that moves the window
local tSound -- the path to the sound to play when bouncing
local leftBound,rightBound,topBound, bottomBound -- the boundaries to bounce within
local sh, tFileList, tName, tLoc, tColor, tWindowsList, item1ScreenRect, item2ScreenRect
local lStopFlag
local theKey
on openCard -- startup code
setMeUp
dropme
end openCard
on setMeUp -- set boundaries, etc.
get the working screenrect
put item 3 of it into rightBound
put item 4 of it into bottomBound
put rightBound div 2 into dx
put bottomBound div 2 into dy
put 0 into leftBound
put rightBound - leftBound into rightBound
put 0 into topBound
put bottomBound - topBound into bottomBound
put 20 into stepx
put 20 into stepy
put "invitation.aiff" into tSound
end setMeUp
on rawKeyUp theKey
 if theKey is 65307 then
  put true into lStopFlag
 else
  pass rawKeyUp
 end if
end rawKeyUp
on closeStack
stopMoving
end closeStack
on closeStackRequest -- when trying to close, stop moving
stopMoving
end closeStackRequest
on escapeKey -- use escape to stop all the stacks
put the windows into tWindowsList
repeat for each line L in tWindowsList -- may have clones bouncing around
if word 1 of the short name of stack L is "bouncy" then send "stopMoving" to this cd of stack L
end repeat
end escapeKey
on stopMoving -- stop any movement and home the stack
cancel tMessage
set the loc of this stack to 300,300
end stopMoving
on setImage pFilePath -- shapes to an image and displays it
put url ("binfile:" & pFilePath) into image 1
set the width of this stack to the width of image 1
set the height of this stack to the height of image 1
set the topleft of image 1 to 0,0
shapeMe
setMeUp
end setImage
on dropme -- handle physics to drop the window
add stepx to dx
add stepy to dy
set the loc of this stack to dx,dy
if (dy + 35) > bottomBound then -- hit bottom limit
put bottomBound -35 into dy
put stepy * (-1) into stepy
end if
if (dy - 35) < topBound then -- hit top limit
put topBound + 35 into dy
put stepy * (-1) into stepy
end if
if (dx + 35) > rightBound then -- hit right limit
put rightbound -35 into dx
put stepx * (-1) into stepx
end if
if (dx - 35) < leftBound then -- hit left limit
put leftbound +35 into dx
put stepx * (-1) into stepx
end if
send "dropme" to me in 1 tick
put the result into tMessage
if lStopFlag is false then
send "dropme" to me in 3 ticks
end if
end dropme
on startdropme
put false into lStopFlag
dropme
end startdropme
=========================
May be also that I have to check for any property?
Thank you,
Carmine
here is all the card script:
======================================
local tDragging -- true if dragging the window, false if not
local dx,dy -- the current x and y movement variable
local sx,sy -- the current x and y coordinates of the stack
local cx,cy -- the location at which the user clicked in the stack to start dragging
local sx0,sy0 -- when slingshotting, the start x and y
local stepx, stepy, inWindow
local tMessage -- the id of the message that moves the window
local tSound -- the path to the sound to play when bouncing
local leftBound,rightBound,topBound, bottomBound -- the boundaries to bounce within
local sh, tFileList, tName, tLoc, tColor, tWindowsList, item1ScreenRect, item2ScreenRect
local lStopFlag
local theKey
on openCard -- startup code
setMeUp
dropme
end openCard
on setMeUp -- set boundaries, etc.
get the working screenrect
put item 3 of it into rightBound
put item 4 of it into bottomBound
put rightBound div 2 into dx
put bottomBound div 2 into dy
put 0 into leftBound
put rightBound - leftBound into rightBound
put 0 into topBound
put bottomBound - topBound into bottomBound
put 20 into stepx
put 20 into stepy
put "invitation.aiff" into tSound
end setMeUp
on rawKeyUp theKey
 if theKey is 65307 then
  put true into lStopFlag
 else
  pass rawKeyUp
 end if
end rawKeyUp
on closeStack
stopMoving
end closeStack
on closeStackRequest -- when trying to close, stop moving
stopMoving
end closeStackRequest
on escapeKey -- use escape to stop all the stacks
put the windows into tWindowsList
repeat for each line L in tWindowsList -- may have clones bouncing around
if word 1 of the short name of stack L is "bouncy" then send "stopMoving" to this cd of stack L
end repeat
end escapeKey
on stopMoving -- stop any movement and home the stack
cancel tMessage
set the loc of this stack to 300,300
end stopMoving
on setImage pFilePath -- shapes to an image and displays it
put url ("binfile:" & pFilePath) into image 1
set the width of this stack to the width of image 1
set the height of this stack to the height of image 1
set the topleft of image 1 to 0,0
shapeMe
setMeUp
end setImage
on dropme -- handle physics to drop the window
add stepx to dx
add stepy to dy
set the loc of this stack to dx,dy
if (dy + 35) > bottomBound then -- hit bottom limit
put bottomBound -35 into dy
put stepy * (-1) into stepy
end if
if (dy - 35) < topBound then -- hit top limit
put topBound + 35 into dy
put stepy * (-1) into stepy
end if
if (dx + 35) > rightBound then -- hit right limit
put rightbound -35 into dx
put stepx * (-1) into stepx
end if
if (dx - 35) < leftBound then -- hit left limit
put leftbound +35 into dx
put stepx * (-1) into stepx
end if
send "dropme" to me in 1 tick
put the result into tMessage
if lStopFlag is false then
send "dropme" to me in 3 ticks
end if
end dropme
on startdropme
put false into lStopFlag
dropme
end startdropme
=========================
May be also that I have to check for any property?
Thank you,
Carmine
Parallel activities +3 (how to stop?)
Dears all,
I made a mistake and now, when I open the stack, the application unables me to open any menu!!??
How can I open a stack without launching the application?
Many thanks,
Carmine
I made a mistake and now, when I open the stack, the application unables me to open any menu!!??
How can I open a stack without launching the application?
Many thanks,
Carmine
Parallel activities +4 (Stopped!!) + Working OK!!!
Dear Mark,
I changed to:
on openCard -- startup code
setMeUp
startdropme
end openCard
from previous:
on openCard -- startup code
setMeUp
dropme
end openCard
While, in dropme handler, I also changed to:
put the result into tMessage
if lStopFlag is false then
send "dropme" to me in 3 ticks
end if
end dropme
from previous:
put the result into tMessage
send "dropme" to me in 1 ticks
if lStopFlag is false then
send "dropme" to me in 3 ticks
end if
end dropme
... and now it is working OK!!
But why?
I made this changes but I didn't really got the inside meaning of it!
Is there any talented Runtime Revolution people to help me?
Very best wishes,
Carmine
I changed to:
on openCard -- startup code
setMeUp
startdropme
end openCard
from previous:
on openCard -- startup code
setMeUp
dropme
end openCard
While, in dropme handler, I also changed to:
put the result into tMessage
if lStopFlag is false then
send "dropme" to me in 3 ticks
end if
end dropme
from previous:
put the result into tMessage
send "dropme" to me in 1 ticks
if lStopFlag is false then
send "dropme" to me in 3 ticks
end if
end dropme
... and now it is working OK!!
But why?
I made this changes but I didn't really got the inside meaning of it!
Is there any talented Runtime Revolution people to help me?
Very best wishes,
Carmine