Hi all,

I have a button that has a rather long script, which includes things like getting the button to move to different places in the card. This script is recursive: when it gets to the end, it calls itself again. I guess, a very simple example that illustrates roughly what is happening would be something like this:

on mouseUp
        move me relative 300,0 in 15 seconds
        move me relative -300,0 in 15 seconds
        send "mouseUp" to me in 1 tick
end mouseUp

The problem is that I also have to delete this object at certain times. Hmmm, not as simple as it may look... If I try to delete a button while it's moving, it tells me that I can't do that, because the object is locked (I guess because its script is executing). So I guess all I need to do is halt the script...

The first thing I tried was to place a 'flag' in the button (as a custom property), that would advise the object when NOT to loop - and then, to delete itself:

on mouseUp
if not(the cStopMoving of me) then move me relative 300,0 in 15 seconds
if not(the cStopMoving of me) then move me relative -300,0 in 15 seconds
if (the cStopMoving of me) then
send "delete me" to me in 10 ticks
else
send "mouseUp" to me in 1 tick
end if
end mouseUp


This approach had 2 problems: first, it didn't work (the button would not delete itself in the end). Second, it meant that even after the flag was set, I still had to WAIT until the movement was finished (15 seconds!) until the deletion was attempted.

So, I started trying to use a second button - a 'delete' button - to try and STOP the movement of the first 'animated' button, and then do the deletion on-the-spot.

The script in the first button now goes:

on mouseUp
move me relative 300,0 in 15 seconds
if not(the cStopMoving of me) then move me relative -300,0 in 15 seconds
if not(the cStopMoving of me) then send "mouseUp" to me in 1 tick
end mouseUp


The script in the 'delete' button goes:

on mouseUp
        set the cStopMoving of button "animatedBtn" to true
        stop moving button "animatedBtn"
        delete button "animatedBtn"
end mouseUp

Hmmm, better results: now, the animated button DOES STOP moving immediately, however, still NO DELETION!

Perhaps I need to give some time for the script of the 'animated' button to do all its flag-checking, and run its course, before I try to delete it - my thinking here is that I might be trying to delete the button while it's locked because its script has not yet finished executing. Ok, so I changed the 'delete' button script to:

on mouseUp
        set the cStopMoving of button "animatedBtn" to true
        stop moving button "animatedBtn"
        put "delete" && the long id of button "animatedBtn" into lMessage
        send lMessage to this stack in 1 second -- should be plenty of time!
end mouseUp     

Guess what?: it still DOES NOT DELETE!!!

What gives?

I feel like I'm overseeing something basic...

Any help GREATLY appreciated!

Cheers,

Igor de Oliveira Couto
------------------------------

_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to