Indigo Rose Software

Professional Software Development Tools

 
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843

    Multiple timer actions

    I need to setup various actions that will take place based on the user clicking on buttons. These actions are time related.
    Ex: 2 objects +2 buttons.
    when user clicks on button1, object1 moves off screen (timer with object position incrmenting).
    Same with object2.

    How can I call a different onTimer trigger for each button?
    Thanks
    Yossi.

    P.s. I don't want AMS to be running constantly in the background a "onTimer" bunch of actions. I think it is inneficient programming technique.

  2. #2
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    I have thought about this as well. My thought was that you could have on timer started but every time it happens you could use two conditional statemements that increment a number, if the number is one then your timer has gone off one time if it is 5 then your timer has gone off 5 times. You can take actions based on this.

    I havent actually tried this but it is the first thought I had on accomplishing what I wanted.

    Page.StartTimer(1000);
    timercounter = 0

    On Timer
    timercounter = timercounter + 1

    Button.SetPos("button1", xpos-5, ypos);

    if timercounter == 2 then
    timercounter = 0;
    Button.SetPos("button2", xpos2 - 5, ypos2);
    end

    Or something like that anyway. This will move button 1 every second and button2 every two seconds.

    I will play with it some more in an actual project and see what I can come up with.

    Tigg.
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  3. #3
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    P.s. I don't want AMS to be running constantly in the background a "onTimer" bunch of actions. I think it is inneficient programming technique.
    I think there may be a misinterpretation of this issue. Running a timer in the background is no problem and many apps which you are currently using no doubt do that, or something similar in the course of running. A background timer for today's computers is far from inefficient. That's what it's there for.

    Just FYI anyhow.

    There's no harm at all in have a timer going. The only issue might arise if you have the timer checking lots and lots of stuff like ten times per second or whatever. But if you're sensible and keep the code to a minimum, you will have no trouble at all.

    Corey Milner
    Creative Director, Indigo Rose Software

  4. #4
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843
    Thanks TJ and Corey (and Rhosk).
    TJ, what I want is a separate control for different objects. Your solution doesn't quiet do it. Thanks though.
    Corey, my impression is that if I have something working all the time (even once every x milliseconds), perfomance would be affected.
    I am trying to work something out like having a condition in the onTimer event which is dependent on a variable value received via the button. Then this or that part of code would be run, depending on the variable value.
    I am not there yet though.
    Yossi

  5. #5
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Yossi, not at all. It's a simple timer, there are so many things happening "per second" on a modern computer that it's amazing.

    For example, you watch video right? Well I can guarantee you it takes a *whole lot* more computer to fully render 15 frames per second at 640 X 480 than it ever will to run a tiny counter.

    Trust me, running a small timer is definitely not an issue for any modrn computer, not even close.

    Corey Milner
    Creative Director, Indigo Rose Software

  6. #6
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843
    I hear ya, Corey. Thanks
    Yossi

  7. #7
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Just FYI Yossi, I'm a slow adapter usually, i.e. you notice we only added DHTML menus to our site here now in 2004 whereas some folks have been doing it since 2000. So I'm totally with you on this one, it took me a while to get used to running timers and not worrying about it. I think for me, my history in Flash is what helped though, some of my Flash movies were firing dozens of instructions per second with corresponding animations and they seem to be OK, so that gives me confidence in page timers.

    I tested them lots, and I haven't found a slow timer yet, but then again, if you really bog one down, in theory it could get slow eventually.

    You could always build in an inertia state where, if nothing requiring the timer is present, it stops - and then restarts as needed. Just a thought.

    Corey Milner
    Creative Director, Indigo Rose Software

  8. #8
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843
    Good idea. Help me here. how do you restart a ontimer event? and I don't mean by clicking or reloading a page.
    Yossi

  9. #9
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Hi. Well you have

    Page.StartTimer();

    and

    Page.StopTimer();

    Which you can use freely to toggle a timer. When it is off, nothing in the timer area will occur, when it's on, everything in that area will occur according to the interval you set.

    For example:

    Page.StartTimer(1000);

    Would set it to fire once per second whereas

    Page.StartTimer(100);

    would be ten times per second, and so forth... Which is another point, for many types of functionality you only need to check something once per second, which is very little CPU load, so try to use the largest increment which suits your needs. But this is to be kept in perpspective too, i.e. to check a variable value ten times per second is also very little load on the CPU, so you be the judge...

    Corey Milner
    Creative Director, Indigo Rose Software

  10. #10
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843
    Corey, I didn't explain myself well enough.
    If onTimer is used in a Page.onShow event, it is launched only once, unless you reload the page.
    You can use a onTimer event with a button.
    I was wondering how do you launch a ontimer event (which would, inturn, check and act based on a time interval)?
    Yossi

  11. #11
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    I'm not sure I understand. Here's how I see it:

    You have a page timer. You can start and stop this page timer freely using the actions listed above. Any actions in the onTimer event will fire according to these. To toggle these on and off I reccomend using conditionals or variables.

    Feel free to post a sample project or give details of a sample scenario, maybe I'll be able to understand that better.

    Corey Milner
    Creative Director, Indigo Rose Software

  12. #12
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843
    ok, scenario:
    I have an image on my page.
    if the user doesn't click on anything, after, let's say 20 seconds, this image starts pulsing (alpha channel value and size values change) . The pulsing is done with an OnTimer action which sets the rythm. Above/before that, there is another ontimer action which is the one checking this 20 second waiting period before launching the second ontimer action.
    A bit muddy, but I hope you got my meaning.
    Thanks for your time, Corey.
    Yossi

  13. #13
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Hi. OK:

    1. We start a timer, set to fire once per second:

    Page.StartTimer(1000);

    2. We set the button to set a variable OnClick, i.e. wait = 1;

    3. In the Timer Event area we add some actions:

    a) an action to increment the variable wait once per second, i.e. wait = wait + 1;

    b) an if statement to check and see if wait = 20 and if it does, initiate the image effect.

    Hope that helps, unless I'm still missing the point, wouldn't be the first time.

    Corey Milner
    Creative Director, Indigo Rose Software

  14. #14
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843
    Sorry for the delay in answering, I do sleep sometimes (unlike some of you, guys.... )
    Yes, it does help. Thanks Corey.
    I am trying to fit my conception of timeline based events or sequencial events in AMS and here lies the problem. Each program has its own "frame of mind". I see that the onTimer event, albeit great in itself isn't a fully time oriented trigger.
    There are almost always some ways or workarounds to get to where to want to go, but it would be nice to have an onTimer trigger attached to objects. That way each onTimer can be independent.
    Thanks a lot, Corey. Great supprot.
    Yossi

  15. #15
    Join Date
    Nov 2003
    Location
    Salzburg / Austria
    Posts
    312
    Little Demo.

    Scripts found in

    Project/Actions
    On StartUp (predefined Variables)

    Page:
    On Timer (Code for waiting and pulsing)
    On Preload (Start Timer)

    Buttons:
    On CLick (Set Variable)


    Stefan
    Attached Files

Page 1 of 2 1 2 LastLast

Similar Threads

  1. rename multiple files
    By jenny62 in forum Setup Factory 6.0
    Replies: 1
    Last Post: 04-13-2004, 01:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts