Page 1 of 1

Problems with audio not stopping after exit

Posted: Wed Nov 13, 2013 1:02 pm
by Sekoshiba
Hello, I'm having an issue with audio files that refuse to stop even after the app has closed. After clicking to exit the page the app remains with processes to continue the music and I cannot figure out why that is...

If there is a syntax like "On exit" or something that I can link to an exit module? Perhaps something along the lines of

"On exit
Stop audio
end exit"

...If so that'd be great :D


Additional query: I am also having issues making two objects move simultaneously, Sometimes it works and sometimes it does not for no discernible reason...Is this just a limitation/bug in livecode? Can I perhaps call the movement module inside another object's movement module so that they are linked and do not contradict eachother? Or, more likely, Am I just being silly and there's a known reason for this happening? :P

Anyhow, Thanks regardless! :)

Re: Problems with audio not stopping after exit

Posted: Wed Nov 13, 2013 1:29 pm
by Klaus
Hi Sekoshiba,

well, please check these stacks to get the basics of Liveocde:
http://www.hyperactivesw.com/revscriptc ... ences.html

Quite important: On what platform (Mac/Win/Mobile) do you want to do this?

1. Stop sound:
How did you start the sound? Neccessary to know the correct command to STOP the sound
You can use the "on closestack" or "closecard" handler to stop your sound.

Maybe "play stop ac" will do?

2. Move:
Please always mention what you did try so far, what scripts you use.

The trick is to "DELEAY" the movement until all objects are "on their way" like this:
...
## PREVENT ALL moves from starting:
LOCK MOVES
## 1. Now move all your objects:
move btn 1 to 512,888 in 2 secs without wainting
move btn 44 to 1024,33 in 3 secs without waiting
## more objects to move here...

## NOW "let them go"
UNLOCK moves
...

Best

Klaus

Re: Problems with audio not stopping after exit

Posted: Fri Nov 15, 2013 12:47 pm
by Sekoshiba
Thanks for the speedy reply, I'm having issues with the "move relative" command...

See, I have an object moving via this command:

"repeat
Move image "image" relative 0,1
If top of image "image" > bottom of card "gamecard" then
set the bottom of "image" image to the top of card "gamecard"
end if
end repeat"

The issue here is that whenever another movement related script initiates the aformentioned movement loop seems to freeze, disallowing several things onscreen to move at once.

I'm not entirely sure how locking and unlocking objects would work...Could I perhaps unlock the movement of all items so that they do not reserve the right to move at that time, thus allowing all items to move uninterrupted?

I mean, with syntax along the lines of:

"Move relative 0,-1
Unlock moves"

PS: Closestack syntax you suggested is working perfectly, thanks again for the help! :D

Re: Problems with audio not stopping after exit

Posted: Fri Nov 15, 2013 12:59 pm
by Klaus
Hi Sekoshiba,

OK, I see.
Well MOVEing an object by just one pixel does not make sense, I would SET the loc instead.

And for your purpose I would NEVER use an ENDLESS repeat loop, this is dangerous if you do not
implement a way to LEAVE the loop under a certain conditon!

Try this using a "SEND IN..." and setting the loc:

Code: Select all

## See below for the meaning of this variable
global tMovigImageID 
command move_the_image
  put the loc of image "image" into tImageLoc

  ## Modify the Y value of the loc and set the loc again:
  ADD 1 to item 2 of tImageLoc
  set the loc of image "image" into tImageLoc
   If top of image "image" > bottom of card "gamecard" then
      set the bottom of "image" image to the top of card "gamecard"
  end if

  ## This is the trick: Use SEND IN TIME instead of a repeat loop, which is blocking as you experienced
  send "move_the_image" to me in 50 millisecs
  ## or any interval that fits your needs

  ## Every message that you SEND in the future will have an ID that you can use to late CANCEL further SENDings
  put the result into tMovigImageID
end move_the_image
Now you can CANCEL/stop all the automatic moving of the imge by something like htis:

Code: Select all

global tMovigImageID
on closestack
  cancel global tMovigImageID 
end closestack
Check "send" in the dictionary, very powerful!


Best

Klaus

Re: Problems with audio not stopping after exit

Posted: Sat Nov 16, 2013 4:17 pm
by Sekoshiba
Thanks very much, I shall try these! :D