Announcement

Collapse
No announcement yet.

built in timer function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • built in timer function

    Hi,
    I know this subject has been dealt with at length, but I found what seems to me an easy way to build a timer function without using outside (flash) objects:
    Stages:
    1. set action (like click on an object)
    2. initialize a variable to a "system.get time" value and check seconds
    3. set a second variable to same
    4. build a conditional statement (if or while) where the second variable constantly gets "system.gettime" current value, AND check value of second variable to value of first variable.
    5. the length on the conditional loop sets the "waiting time".

    here follows the XML code:

    <IR_ACTIONS_LIST>
    <Action name="Get Date Time">
    <Type>139</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%t1%</Variable>
    <ReturnType>1</ReturnType>
    <Date>0</Date>
    <Time>2</Time>
    </Action>
    <Action name="Get Date Time">
    <Type>139</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%t%</Variable>
    <ReturnType>1</ReturnType>
    <Date>0</Date>
    <Time>2</Time>
    </Action>
    <Action name="WHILE">
    <Type>204</Type>
    <Function>1</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Condition>%t% &amp;lt;= %t1%+5</Condition>
    </Action>
    <Action name="Get Date Time">
    <Type>139</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <Variable>%t%</Variable>
    <ReturnType>1</ReturnType>
    <Date>0</Date>
    <Time>2</Time>
    </Action>
    <Action name="END WHILE">
    <Type>205</Type>
    <Function>1</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    </Action>
    <Action name="Jump">
    <Type>1</Type>
    <Function>0</Function>
    <DTIndentLevel>0</DTIndentLevel>
    <Enabled>1</Enabled>
    <ErrorHandling>
    <UserNotificationMode>2</UserNotificationMode>
    <CustomErrorMessage/>
    <OnErrorAction>0</OnErrorAction>
    <JumpToLabel/>
    </ErrorHandling>
    <PageName>page2</PageName>
    </Action>
    </IR_ACTIONS_LIST>

    Looks to me a good work around...untill a "wait" object will be included into AMS.

    Hope that helps.

    Yossi

  • #2
    Re: built in timer function

    How is this any different from using the Application.Sleep action?

    BTW, it looks like your actions could get stuck in an infinite loop if the button is clicked when the current time is between 56 and 59 seconds into the minute, e.g. at 10:54:57. %t% would always be less than 62 in this case, and the while loop would go on forever.
    --[[ Indigo Rose Software Developer ]]

    Comment


    • #3
      Re: built in timer function

      Hi Lorne,
      First of all. you are 100% right about the endless loop. Thing to do is to add an if function checking the value of the seconds.
      As to the difference between this and application sleep: with "sleep", user has no control of the interface (buttons etc) till after "sleeping period" with this wait loop, user can still interact with the interface.
      And a WAIT function would be more than welcome...
      Cheers,
      Yossi

      Comment


      • #4
        Re: built in timer function

        Yes Yosik you are right about that for sure, a WAIT function is badly needed in AMS as is evidenced by the many threads on this very same topic. If I had a nickel for every user which asked for a way to wait without disabling the interface I would be rich.

        Corey Milner
        Creative Director, Indigo Rose Software

        Comment


        • #5
          Re: built in timer function

          Weird, yosik, when I ran that while loop, I could not interact with the interface...mouseovers didn't register, for example.

          Can you give me an example of the kind of interaction you mean?
          --[[ Indigo Rose Software Developer ]]

          Comment


          • #6
            Re: built in timer function

            What if you were to do it this way? I have kept your same functions but added an IF/ENDIF statement where it will look at %t1% and if it is > 60 it will subtract 60 from the total value. And I changed the while loop to be WHILE (%t% != %t1%). so it would have to be equal to %t1% to end the loop. Check it out.


            <IR_ACTIONS_LIST>
            <Action name="Get Date Time">
            <Type>139</Type>
            <Function>0</Function>
            <DTIndentLevel>0</DTIndentLevel>
            <Enabled>1</Enabled>
            <ErrorHandling>
            <UserNotificationMode>2</UserNotificationMode>
            <CustomErrorMessage/>
            <OnErrorAction>0</OnErrorAction>
            <JumpToLabel/>
            </ErrorHandling>
            <Variable>%t1%</Variable>
            <ReturnType>1</ReturnType>
            <Date>0</Date>
            <Time>2</Time>
            </Action>
            <Action name="Set Value">
            <Type>6</Type>
            <Function>0</Function>
            <DTIndentLevel>0</DTIndentLevel>
            <Enabled>1</Enabled>
            <ErrorHandling>
            <UserNotificationMode>2</UserNotificationMode>
            <CustomErrorMessage/>
            <OnErrorAction>0</OnErrorAction>
            <JumpToLabel/>
            </ErrorHandling>
            <Variable>%t1%</Variable>
            <Value>%t1% + 5</Value>
            <Evaluate>1</Evaluate>
            </Action>
            <Action name="IF">
            <Type>200</Type>
            <Function>1</Function>
            <DTIndentLevel>0</DTIndentLevel>
            <Enabled>1</Enabled>
            <ErrorHandling>
            <UserNotificationMode>2</UserNotificationMode>
            <CustomErrorMessage/>
            <OnErrorAction>0</OnErrorAction>
            <JumpToLabel/>
            </ErrorHandling>
            <Condition>%t1% &amp;gt; 60</Condition>
            </Action>
            <Action name="Set Value">
            <Type>6</Type>
            <Function>0</Function>
            <DTIndentLevel>1</DTIndentLevel>
            <Enabled>1</Enabled>
            <ErrorHandling>
            <UserNotificationMode>2</UserNotificationMode>
            <CustomErrorMessage/>
            <OnErrorAction>0</OnErrorAction>
            <JumpToLabel/>
            </ErrorHandling>
            <Variable>%t1%</Variable>
            <Value>%t1% - 60</Value>
            <Evaluate>1</Evaluate>
            </Action>
            <Action name="END IF">
            <Type>201</Type>
            <Function>1</Function>
            <DTIndentLevel>0</DTIndentLevel>
            <Enabled>1</Enabled>
            <ErrorHandling>
            <UserNotificationMode>2</UserNotificationMode>
            <CustomErrorMessage/>
            <OnErrorAction>0</OnErrorAction>
            <JumpToLabel/>
            </ErrorHandling>
            </Action>
            <Action name="Get Date Time">
            <Type>139</Type>
            <Function>0</Function>
            <DTIndentLevel>0</DTIndentLevel>
            <Enabled>1</Enabled>
            <ErrorHandling>
            <UserNotificationMode>2</UserNotificationMode>
            <CustomErrorMessage/>
            <OnErrorAction>0</OnErrorAction>
            <JumpToLabel/>
            </ErrorHandling>
            <Variable>%t%</Variable>
            <ReturnType>1</ReturnType>
            <Date>0</Date>
            <Time>2</Time>
            </Action>
            <Action name="WHILE">
            <Type>204</Type>
            <Function>1</Function>
            <DTIndentLevel>0</DTIndentLevel>
            <Enabled>1</Enabled>
            <ErrorHandling>
            <UserNotificationMode>2</UserNotificationMode>
            <CustomErrorMessage/>
            <OnErrorAction>0</OnErrorAction>
            <JumpToLabel/>
            </ErrorHandling>
            <Condition>%t% != %t1%</Condition>
            </Action>
            <Action name="Get Date Time">
            <Type>139</Type>
            <Function>0</Function>
            <DTIndentLevel>1</DTIndentLevel>
            <Enabled>1</Enabled>
            <ErrorHandling>
            <UserNotificationMode>2</UserNotificationMode>
            <CustomErrorMessage/>
            <OnErrorAction>0</OnErrorAction>
            <JumpToLabel/>
            </ErrorHandling>
            <Variable>%t%</Variable>
            <ReturnType>1</ReturnType>
            <Date>0</Date>
            <Time>2</Time>
            </Action>
            <Action name="END WHILE">
            <Type>205</Type>
            <Function>1</Function>
            <DTIndentLevel>0</DTIndentLevel>
            <Enabled>1</Enabled>
            <ErrorHandling>
            <UserNotificationMode>2</UserNotificationMode>
            <CustomErrorMessage/>
            <OnErrorAction>0</OnErrorAction>
            <JumpToLabel/>
            </ErrorHandling>
            </Action>
            <Action name="Jump">
            <Type>1</Type>
            <Function>0</Function>
            <DTIndentLevel>0</DTIndentLevel>
            <Enabled>1</Enabled>
            <ErrorHandling>
            <UserNotificationMode>2</UserNotificationMode>
            <CustomErrorMessage/>
            <OnErrorAction>0</OnErrorAction>
            <JumpToLabel/>
            </ErrorHandling>
            <PageName>page2</PageName>
            </Action>
            </IR_ACTIONS_LIST>
            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

            Comment


            • #7
              Re: built in timer function

              Don't we come back to the issue raised in earlier posts - the loop speed being governed by the PC?
              -
              = Derek
              ["All glory comes from daring to begin" - fortune cookie]

              Comment


              • #8
                Re: built in timer function

                Lorne,
                example:
                A quiz. Question is asked. Time is measured. If user answers during wait period, he "gets a point" if time runs out, script goes to next question and he "looses a point". But there are 100s of possible scenarios based on wait command.
                Yossi

                Comment


                • #9
                  Re: built in timer function

                  Actually, I meant what kind of interaction STILL WORKS during a while loop. [img]/ubbthreads/images/icons/smile.gif[/img]

                  When I ran your example, no mouseovers or mouse clicks would work. The whole AutoPlay application froze up just like Application.Sleep.

                  Other people seem to believe you, so I must be missing something. [img]/ubbthreads/images/icons/smile.gif[/img]
                  --[[ Indigo Rose Software Developer ]]

                  Comment


                  • #10
                    Re: built in timer function

                    You are right Lorne, mouseclick or mouseover don't work, but for example, textbox are still "alive" (scrolling etc..) and so are other objects.
                    The problem is that while I interact with the object, the function which checks the variable value against the time value is suspended. So in that case, I "miss" the trigger.
                    Definitely, a simple wait function is needed.

                    Yossi

                    Comment


                    • #11
                      Re: built in timer function

                      For now, why not use Corey's excellent Flash timer:

                      http://www.indigorose.com/ubbthreads...amp;sb=&amp;o=
                      --[[ Indigo Rose Software Developer ]]

                      Comment


                      • #12
                        Re: built in timer function

                        I have a way...I worked out a way to make a simple timer and it works ok. Its the type you would use to change a picture after a certain amount of time or to change variables per second. Anyways here it is: In the page initialize or project initialize set a variable say %time% to 0. Then have it load and set repeat to true for the mp3 file included. This file is exactly 1sec so is fairly acurate and leaves FULL project functionality. Now you can either set an image or have it autostart in the project or page initialize but now you need to set mp3 to play. Now click project>mp3 player and select "on song end" then set variable %time%o evaluate %time% + 1 after this you can then do any if controls etc. or say you want to hide a pic every 10sec then all you need to do is an if %time% = 10 then evaluate %time% to 0 and then do your function. Hope this helped you all. Ohh and yeah some of u might like to know the site so here it is http://planet8software.tripod.com/1sec.mp3

                        Comment

                        Working...
                        X