Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Corey
    Indigo Rose Staff Alumni
    • Aug 2002
    • 9741

    Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

    OK so it has been asked a lot so here it is. An easy to use timer (Flash v5). You can set how fast it loops (anywhere from 10 loops per second to ten seconds per loop) and how many times it loops (use zero for no limit). It returns fscommands (contains current loop number) on each loop completion and again on finish. Very easy to use, readme file (as pasted below) and sample file are included in the download as well as the original timer Macromedia Flash source file. It's super easy to use this timer and it's reasonably accurate. Also because it uses frame cycling to generate pauses rather than a WHILE or DO loop, it will not slow down your applications. Have fun, if you have any questions feel free to ask... Also feel free to use any of the code in this .zip file in any of your projects.



    Contents of readme.txt:

    FLASH TIMER READ ME FILE - INDIGO ROSE SOFTWARE 2003
    by Corey Milner - Creative Director Indigo Rose Software.

    Hi everyone, here's an easy-to-use timer you can use within your AutoPlay Media Studio projects to time things or trigger events, etc. The timer requires two pieces of info to run, a loop rate and a loop limit. This allows you to specify how long each loop takes and how many loops occur. The timer returns 2 pieces of info to AMS via fscommands, it sends the loop iteration number, i.e. "10" at the end of each loop and then it sends a "done" message after the last loop. You can use these events to trigger anything you want. OK so let's take a look at how to use it (sample file is included, open it up in AMS and check it out, it's very easy to understand).

    1. Drop the file timer.swf into your project's "Resources" folder.
    2. Create a new Flash Object on your page, point it to the file timer.swf (change background color if need be, timer is 1 X 1 pixels white)
    3. Decide how fast you want the timer to loop. The options allow you to specify any number between .1 and 10 , the number being "How many seconds per loop". So if you want it to loop once per second you would use 1, if you want it to loop once every 5 seconds you would use 5, etc.
    4. Decide how many loops you want the timer to make before ending. This can be any non-negative number, If you wish it to loop forever use a zero.
    5. OK now that we have our timer inserted and we know our stats we'll insert the values. Just use a FLASH OBJECT > SET VARIABLE action to set timer.swf's Flash variable "loopRate" to whatever number you chose in step 3 then use another FLASH OBJECT > SET VARIABLE action to set timer .swf's Flash variable "loopLimit" to whatever number you chose in step 4 above.
    6. To be safe insert a FLASH OBJECT > SEEK action and set it to go to frame zero, then insert a FLASH OBJECT > PLAY action. That's it, your timer is working.

    To retrieve info from your timer

    1. The timer itself transmits an fscommand containing the current loop number at the end of each loop, i.e. 1, 2, 3, etc... To use this info to trigger actions go to your timer.swf's Flash Object properties and add a FLASH OBJECT > GET PROPERTY > LAST FSCOMMAND action to the OnFSCommand event, this will read the last fscommand transmitted into a variable which you can then test with an IF statement to trigger anything you like, i.e. "IF loop = 5 then start video", etc...

    2. The timer also transmits the fscommand "done" when all the loops have been completed. Use the same technique above to retrieve this into a variable for testing, etc.

    A couple final notes. This timer is not completely accurate in terms of time and timing will vary slightly from fast systems to slow systems, but overall it's pertty reliable and because it uses a frame cycling as a timer methodology rather than a WHILE or DO loop, it chews up no resources at all while it's running in the background of your AMS application page. NOTE I tried many different techniques, even using microtime, etc. but this frame cycling method was the only one I found which was reasonably accurate and could fire many times per second without slowing down your application)

    Hope you guys enjoy using this, if there's any questions just post them in the user forum at www.indigorose.com. TTYL. [img]/ubbthreads/images/icons/smile.gif[/img]


    Corey Milner - Creative Director Indigo Rose Software.
    AutoPlay Media Studio is a registered trademark of Indigo Rose Software, all rights reserved. This training material copyright 2003 Indigo Rose Software, feel free to share it with friends but please keep this readme and all included files intact and unaltered in all distributed copies.

    Corey Milner
    Creative Director, Indigo Rose Software
  • CelticDragon
    Indigo Rose Customer
    • Jun 2003
    • 87

    #2
    Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

    Hey Cory,

    Sorry to bother you, but I'm having problems with this one! (What I surprise I hear you shout!)

    I have set the page properties to hide all objects, then show flash1 and text 1 (ie: the three images are hidden)

    Then on mouse click of the text 1 :
    Page.ShowObject ("Image1")
    FlashObject[Flash1].SetVariable (""LoopLimit"", "5")
    FlashObject[Flash1].SetVariable (""LoopRate"", "5")
    FlashObject[Flash1].Seek (0)
    FlashObject[Flash1].Play
    Page.HideObject ("Image1")
    Page.ShowObject ("Image2")
    FlashObject[Flash1].SetVariable (""LoopLimit"", "5")
    FlashObject[Flash1].SetVariable (""LoopRate"", "5")
    FlashObject[Flash1].Seek (0)
    FlashObject[Flash1].Play
    Page.ShowObject ("Image3")
    Page.HideObject ("Image2")
    FlashObject[Flash1].SetVariable (""LoopLimit"", "5")
    FlashObject[Flash1].SetVariable (""LoopRate"", "5")
    FlashObject[Flash1].Seek (0)
    FlashObject[Flash1].Play
    Page.HideObject ("Image3")

    But it's still whipping through all pictures in a second and hiding them all.... Any advice would be greatly appreciated, and if I've missed something really basic and stupid I will understand and accept a ranting tirade of abuse!

    Thanks
    Stephen
    If you can read this, i have yet to write a witty and imaginative signature.... sorry...

    Comment

    • Corey
      Indigo Rose Staff Alumni
      • Aug 2002
      • 9741

      #3
      Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

      Hi.

      1. You attach the trigger actions to the flash object not the page. Check out the readme file, or open up the sample file and check out the actions attached to the Flash timer object itself.

      2. You don't need to restart the timer for each loop, you just read the loop number. So if you want 3 loops of 5 seconds each then you set loopLimit to be 3 and loopRate to be 5 then just seek to 0 and start the Flash object once only.

      Rename your image objects to be 1, 2, and 3. Then simply attach, to your Flash timer object's OnFSCommand event a FLASH OBJECT > GET PROPERTY action to get the Last FScommand. Then one action to hide the last image, and another to show the image which corresponds to the last FSCommand you read in from your flash object, i.e. loop 1 shows object 1, loop 2 shows object 2, etc...

      Corey Milner
      Creative Director, Indigo Rose Software

      Comment

      • CelticDragon
        Indigo Rose Customer
        • Jun 2003
        • 87

        #4
        Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

        also tried declaring the Last FS Command in the flash file as %Property% and changing the on mouse click of the text file to:

        Page.ShowObject ("Image1")
        FlashObject[Flash1].SetVariable ("LoopLimit", "3")
        FlashObject[Flash1].SetVariable ("LoopRate", "3")
        FlashObject[Flash1].Seek (0)
        FlashObject[Flash1].Play
        IF (%Property% = "Done")
        Page.HideObject ("Image1")
        Page.ShowObject ("Image2")
        END IF
        FlashObject[Flash1].SetVariable ("LoopLimit", "3")
        FlashObject[Flash1].SetVariable ("LoopRate", "3")
        FlashObject[Flash1].Seek (0)
        FlashObject[Flash1].Play
        IF (%Property% = "Done")
        Page.ShowObject ("Image3")
        Page.HideObject ("Image2")
        END IF
        FlashObject[Flash1].SetVariable ("LoopLimit", "3")
        FlashObject[Flash1].SetVariable ("LoopRate", "3")
        FlashObject[Flash1].Seek (0)
        FlashObject[Flash1].Play
        IF (%Property% = "Done")
        Page.HideObject ("Image3")
        END IF

        It's showing Image one but not doing much else.... any ideas?
        If you can read this, i have yet to write a witty and imaginative signature.... sorry...

        Comment

        • Corey
          Indigo Rose Staff Alumni
          • Aug 2002
          • 9741

          #5
          Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

          Yeah, again, you need to attach the trigger actions (the hide and show actions) to your flash timer object, not the page. And you need to have the Flash seek and start actions on the page not the flash timer object. You appear to have combined them in some way, this is the source of your problem.

          I suggest reading the readme file very carefully which explains it all, or if you prefer to learn by example, to open the sample file and observe the actions which are attached to the page and also the actions which are attached to the flash timer object itself. It's pretty easy to figure out once you take a look.

          Additionally I reiterate, the correct usage is to start the timer once only, specifying how many total loops you need and how long each should be. Restarting the timer from scratch for each loop is not only inefficient but it also creates unpredictable pauses in your loops as you start and restart the same timer over and over... Like I say, if you want 3 loops then set your loopLimit to 3 and start it only once, i.e. if you want 5 loops then set loopLimit to 5, if you want 10 loops then set loopLimit to 10, etc...

          Corey Milner
          Creative Director, Indigo Rose Software

          Comment

          • CelticDragon
            Indigo Rose Customer
            • Jun 2003
            • 87

            #6
            Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

            Hey Cory,

            Sorry, I tried to post earlier but my net connection isn't great. Posted my second post up there before I read yours, then sat down and went through everything again and now it's working perfectly! Thanks a million and sorry for the stupidity and confusion!

            By the times beside your posts you are either a vampire or a very early riser!

            Stephen
            If you can read this, i have yet to write a witty and imaginative signature.... sorry...

            Comment

            • Corey
              Indigo Rose Staff Alumni
              • Aug 2002
              • 9741

              #7
              Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

              Early rising pseudo-vampire (and self described David Niven clone) actually. Nowhere near as charming as it sounds though. My incessant usage of the word, "Darling", cognac stains on the corgi, and so forth. But we jolly well do what we can...

              Glad the timer's working for you... No probs at all on the posts. [img]/ubbthreads/images/icons/smile.gif[/img]

              Corey Milner
              Creative Director, Indigo Rose Software

              Comment

              • TJ_Tigger
                Indigo Rose Customer
                • Sep 2002
                • 3159

                #8
                Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

                I was suprised to see posts from you so early in the morning Corey. I could see Brett with child and all being up early . . .

                I will have to look at the timer. I am still trying to put one together from the one you posted earlier and the one AGRO did. I want it cafeteria style, a little here and a little there. . .
                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

                • CelticDragon
                  Indigo Rose Customer
                  • Jun 2003
                  • 87

                  #9
                  Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

                  HAHA!!!!!

                  Was about to post a message saying I couldn't get it to loop for me, then I thought of simply putting a "If %Property% = 15 (end of show) then flashobject. seek. (0)


                  Woo, Yay and Houpla, for she works!
                  If you can read this, i have yet to write a witty and imaginative signature.... sorry...

                  Comment

                  • CelticDragon
                    Indigo Rose Customer
                    • Jun 2003
                    • 87

                    #10
                    Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

                    ahhhhhhhhhh..............

                    I don't get it! Everytime I think I have it working, I try to add to it and then it doesn't work again!!!!!!!!!

                    I'm pulling my hair out here!

                    I've tried to use the timer and had it working with three images but then when I set it with more than three different images it didn't work again. Then it did work and looped. Then I added a caption for the images with a set text action for the loops and then it didn't loop... and then somehow it looped the set texts but didn't loop the images.... ahhhhhhhhhhhhhhhhhhhhhhh

                    I don't suppose there is a tutorial for using the timer as a slideshow anywhere is there? I just can't get this to work properly!

                    Sorry for constantly annoying people about this, but for some reason I just don't seem to be able to grasp it...
                    If you can read this, i have yet to write a witty and imaginative signature.... sorry...

                    Comment

                    • Corey
                      Indigo Rose Staff Alumni
                      • Aug 2002
                      • 9741

                      #11
                      Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

                      No there's no video for this one. It's pretty simple so I didn't bother. There's not much to go wrong. Checklist:

                      1. Make sure you tell the timer how many loops to make and how long per loop by setting the Flash object's loopLimit and loopRate parameters from your main page then seek to frame zero and pla the flash object using actions still on your page.

                      2. Attach to the "OnFSCommand" event of your timer a GET PROPERTY action to get the last fscommand into a variable, i.e. %command% and then use thatr to trigger events, i.e. if %command = 1 show image 1, if %command% = 2 show image 2, etc...

                      If you had it working then you know. [img]/ubbthreads/images/icons/smile.gif[/img] Part of the fun of being a developer/designer is stretching the limits of tools, sometimes that means a few grey hairs. Keep trying, all I can say is that if you had it working once you can get it working again. Take your time, break things down, use a list, test your app by inserting dialogs in key spots to see what's going wrong, etc...

                      Corey Milner
                      Creative Director, Indigo Rose Software

                      Comment

                      • CelticDragon
                        Indigo Rose Customer
                        • Jun 2003
                        • 87

                        #12
                        Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

                        Ok, here's what I don't get and I'm starting to think it's a problem with my computer. Last night I figured out pretty much most of it, and had a slideshow going in a constant loop with 20 images and text associated with each image. Then, I tried to change the timing in the flash file, went to test it and it didn't move at all. So I reverted back to before I made those changes (to when it worked!) and then it didn't work at all. Later went back to it and it worked straight away without me doing anything, then went to test it again and nothing.

                        Other question, even when it doesn't work it still shows the first image which is supposed to be hidden on initialize and the flash object is supposed to call it when %Property% = 1. On page show I have set %Property% = 0 and it still shows, even when the show doesn't run.

                        I remember reading on here that sometimes flash is not reliable in terms of timing. Do you think this might be the case? I can't understand why it will work one time then when I change the loop rate to make the pictures stay up longer it doesn't work. I even tried testing twice in a row without making changes and it didn't run the second time..... Loop Limit I have always set to 0 as I want the slide show to run indefinitely while people are reading the text.

                        This really isn't working for me! Does anyone know of a product that can change powerpoint slides to flash, I remember seeing something like that a while ago but can't find it. Do people think this might be a better option?

                        It's 9.40am and I've probably asked a hundred questions on this already...... sorry

                        I've uploaded a copy of my project in zip format <a href="http://za.msnusers.com/TheLurkingIrishman/Documents/Test.zip">here</a>
                        If you can read this, i have yet to write a witty and imaginative signature.... sorry...

                        Comment

                        • Corey
                          Indigo Rose Staff Alumni
                          • Aug 2002
                          • 9741

                          #13
                          Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

                          Naw it's not the Flash, like you say it worked at one time. not sure about your comp but I doubt that's it either for the same reason. I'm sure it's just something minor you tweaked or something. When I get where you are I usually start from scratch and eventually it all falls into place. Like I say, it costs me a few grey hairs from time to time but it's part of the game.

                          Not sure about the powerpoint thing, check Google, that might help.

                          Corey Milner
                          Creative Director, Indigo Rose Software

                          Comment

                          • CelticDragon
                            Indigo Rose Customer
                            • Jun 2003
                            • 87

                            #14
                            Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

                            4.06am?!?!?

                            God **** Man! Don't you EVER sleep?!?!?! I think I'm going to leave the timer for a while, it is driving me insane at the moment! I managed to find that program for converting powerpoint to flash if anyone is interested: www.presentationpro.com and they have a free download trial (which I am downloading as I type this) so I will let you know if it's any good if you are interested.

                            I'm thinking that it might be a more straightforward option for now for doing a slideshow.

                            Go to bed man! Talk to you later, and thanks again for all the help!
                            If you can read this, i have yet to write a witty and imaginative signature.... sorry...

                            Comment

                            • Corey
                              Indigo Rose Staff Alumni
                              • Aug 2002
                              • 9741

                              #15
                              Re: Here's an easy-to-use fully configurable general purpose Flash timer for your projects...

                              I get plenty of sleep, as a matter of fact I'm sleeping right now. Zzzzzzzzz... See?

                              Corey Milner
                              Creative Director, Indigo Rose Software

                              Comment

                              Working...
                              X