waits and movements again

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
kevin11
Posts: 101
Joined: Thu Aug 11, 2011 5:02 pm

waits and movements again

Post by kevin11 » Thu Feb 09, 2012 3:13 pm

I have an app that creates a load of fields and images off screen, and moves them on screen when the creation has finished. If the user clicks to "turn the page", the objects need to move off the screen, and then a new set of objects is created off-screen and moved into place. I'm having problems with making sure the new objects aren't created and moved into view before the previous objects have moved off and been killed. Hence my earlier posts under movement, and wait.

So I've attached a little test stack. Once you hit the start button, it should create 3 fields and move them to final positions. When you hit "Next", it moves the fields off and deletes them. So far, so good. However, when the "Next" button is clicked, ideally the fields should move off and be deleted, and the do_arrival routine can then be executed to repopulate the page, as it were. I've commented out the do_arrival line in the Next button handler.

Now, can anybody uncomment that do_arrival line and get the do_arrival bit to work after the do_departure has finished all its moves ? I've tried checking move counters, issuing wait commands, etc. Swearing has had no effect at all, and the police have refused to get involved.
Attachments
Test.zip
(1.31 KiB) Downloaded 60 times

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2786
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: waits and movements again

Post by mwieder » Thu Feb 09, 2012 6:32 pm

Well, your code seems a little convoluted and I'm not sure I would take this approach, but...

if you can guarantee that there are only three fields you're going to work with, how about something like

Code: Select all

command transition field_name, final_loc, t_millisec
   add 1 to move_count
   move field field_name to final_loc in t_millisec millisec without waiting
   if field_name is "C" and departure is false then
      do_arrival
   end if
end transition
<what does the "without waiting" clause do?>

kdjanz
Posts: 142
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Re: waits and movements again

Post by kdjanz » Thu Feb 09, 2012 6:43 pm

Why wouldn't you have two cards with things in place, then just move from one to the other with a nice transition? All this moving seems to be pretty convoluted...

But I'm not the designer, so you may have a good reason or two.

Kelly

kevin11
Posts: 101
Joined: Thu Aug 11, 2011 5:02 pm

Re: waits and movements again

Post by kevin11 » Thu Feb 09, 2012 6:47 pm

Unfortunately that sends do_arrival into an infinite loop !

kevin11
Posts: 101
Joined: Thu Aug 11, 2011 5:02 pm

Re: waits and movements again

Post by kevin11 » Thu Feb 09, 2012 6:55 pm

kdjanz wrote:Why wouldn't you have two cards with things in place, then just move from one to the other with a nice transition? All this moving seems to be pretty convoluted...

But I'm not the designer, so you may have a good reason or two.
Kelly
The client has seen this :

http://heuristicmedia.tv/apps/cyclepedia.html

Which I am sure you agree is not a card moving from to the other with a nice transition ! In fact, it's very convoluted, but does break down into simple steps.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: waits and movements again

Post by Dixie » Thu Feb 09, 2012 7:29 pm

Kevin11...

Bernd Niggeman posted this a a solution to scaling and moving images
http://forums.runrev.com/phpBB2/viewtop ... 042#p37952
You might get some ideas from the stack...

be well

Dixie

kevin11
Posts: 101
Joined: Thu Aug 11, 2011 5:02 pm

Re: waits and movements again

Post by kevin11 » Thu Feb 09, 2012 8:00 pm

Dixie wrote:Kevin11...

Bernd Niggeman posted this a a solution to scaling and moving images
http://forums.runrev.com/phpBB2/viewtop ... 042#p37952
You might get some ideas from the stack...

be well

Dixie
Thanks Dixie. Unfortunately that doesn't address the problem, but interesting anyway.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2786
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: waits and movements again

Post by mwieder » Thu Feb 09, 2012 9:05 pm

You're probably looking for something more like this, no? The test for done is at the end of the transition handler. This should get you started anyway.
Attachments
Test.zip
Rewritten script file
(1.95 KiB) Downloaded 63 times

kevin11
Posts: 101
Joined: Thu Aug 11, 2011 5:02 pm

Re: waits and movements again

Post by kevin11 » Fri Feb 10, 2012 2:11 am

mwieder wrote:You're probably looking for something more like this, no? The test for done is at the end of the transition handler. This should get you started anyway.
Many thanks for this. Unfortunately, one of the critical requirements is that A,B and C are deleted at the end of the moves. This is because, as pages are turned, A,B, and C may be new fields, images, players, etc. That is, the newly arriving ABC may be different types than the departing ABC. Hence the departing ones have to die. Rather than do a test script with different types of object, I merely supplied fields, with the requirement that they die. If you manage to delete A,B, and C, and still have things work, I will fly to California and buy you a beer !

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2786
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: waits and movements again

Post by mwieder » Fri Feb 10, 2012 2:22 am

So... let me paraphrase that to see if I've understood what you're looking for...

On any given page:
Start with no objects.
Objects (of various types) will arrive.
Those same objects will depart.
After an object departs, it will be deleted.
End with no objects.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2786
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: waits and movements again

Post by mwieder » Fri Feb 10, 2012 5:31 am

Well, I've tried to make this as generic as possible, given the parameters you've set up. It still creates three fields named A, B, and C, but both the object types and names can be easily changed. I believe you were trying to overthink the move/deletion thing - I separated out the move-on-arrival event from the move-on-departure event (one is synchronous, the other asynchronous) and that made the deletion when done easy. And given what I think you have in mind, moving pictures on and off the screen like the bicycle thing, I offloaded some of the functionality into a behavior button.

But what I don't get is why the insistence on deleting the objects? If you're going to be dealing with images, are they going to be external to the application and loaded at runtime? Otherwise, why not just show and hide them rather than creating them from scratch and deleting them? No doubt I've got the wrong idea about the whole thing.

...and don't fly to California - fly to New Jersey in June and come to the conference... we can buy each other a round.
Attachments
Test.zip
revised version
(4.18 KiB) Downloaded 63 times

kevin11
Posts: 101
Joined: Thu Aug 11, 2011 5:02 pm

Re: waits and movements again

Post by kevin11 » Fri Feb 10, 2012 9:49 am

Thank you for this. I'm not sure how to get a new set of arrivals once Next has been clicked and the originals have departed.

To re-paraphrase your paraphrase :

On any given page:
Start with no objects.
Objects (of various types) will arrive, at any speed, with any delay to their start time
Those same objects will depart (most likely with the same delays and speeds they arrived with)
After an object departs, it will be deleted.
When all objects have departed(and been deleted), a new set arrives.

and, you can't rely on the last field to be given a move instruction to be the last field that stops (due to the delays and different speeds that might apply)

I was deleting the controls because I felt that ram usage would slowly increase if hundreds of pages are used each leaving populated controls. However, different controls could be used for new arrivals, in which case an arrival can be followed with a hunt and destroy mission for old departed controls.

However, the real problem is detecting when all moves have stopped and then starting the new arrivals, you can't rely on control C being the final completed move. People have suggested incrementing a move counter on move starts and decrementing on move stops, and then starting the new arrivals when the move counter gets to zero, via a wait statement. But wait doesn't seem to work, it freezes the program and stops the moves.

I could have supplied a script that tries to do this, but it either hangs the machine or trashes things, and I didn't want to upload a poisonous pill for people, so instead I have had to be verbose about it all, I apologise if I am being unclear as a result.

I am beginning to think this problem does not have a solution, unlesss you can get your latest script to trigger an arrival on the Next button !

I like your writing style by the way, seems to be a lot more elegant than mine.

New Jersey eh ? I have relatives there I should visit, so there's a thought.

kevin11
Posts: 101
Joined: Thu Aug 11, 2011 5:02 pm

Re: waits and movements again

Post by kevin11 » Fri Feb 10, 2012 10:50 am

oh ! I think I've solved it. Using one of your suggestions !
Have to test it more thoroughly first though.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”