Page 1 of 1

waits and movements again

Posted: Thu Feb 09, 2012 3:13 pm
by kevin11
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.

Re: waits and movements again

Posted: Thu Feb 09, 2012 6:32 pm
by mwieder
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?>

Re: waits and movements again

Posted: Thu Feb 09, 2012 6:43 pm
by kdjanz
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

Re: waits and movements again

Posted: Thu Feb 09, 2012 6:47 pm
by kevin11
Unfortunately that sends do_arrival into an infinite loop !

Re: waits and movements again

Posted: Thu Feb 09, 2012 6:55 pm
by kevin11
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.

Re: waits and movements again

Posted: Thu Feb 09, 2012 7:29 pm
by Dixie
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

Re: waits and movements again

Posted: Thu Feb 09, 2012 8:00 pm
by kevin11
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.

Re: waits and movements again

Posted: Thu Feb 09, 2012 9:05 pm
by mwieder
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.

Re: waits and movements again

Posted: Fri Feb 10, 2012 2:11 am
by kevin11
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 !

Re: waits and movements again

Posted: Fri Feb 10, 2012 2:22 am
by mwieder
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.

Re: waits and movements again

Posted: Fri Feb 10, 2012 5:31 am
by mwieder
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.

Re: waits and movements again

Posted: Fri Feb 10, 2012 9:49 am
by kevin11
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.

Re: waits and movements again

Posted: Fri Feb 10, 2012 10:50 am
by kevin11
oh ! I think I've solved it. Using one of your suggestions !
Have to test it more thoroughly first though.