10 Replies Latest reply on Sep 19, 2011 10:16 AM by Jim Wiley

    Creating a Timer w/o setInterval or setTimeout

    Jim Wiley Level 1

      Hi All,

      I have an old Macromedia program - Authorware, that doe not like the SWF file output from the new CS Flash.

      I am able to go back to the old Flash version to get output that works - only 4-5 versions back - MX2004 or maybe CS.

       

      I need to create an equivalent using timeline controls?

       

      I was thinking of using a onEnterFrame. Have it loop till frame cycles hit the time I need i.e. 24 fps x 2sec = 48 frame cycles.

      then I would advance the main play head.

       

      Does any one have an example. Or other ideas?

      Thanks,

      Jim

        • 1. Re: Creating a Timer w/o setInterval or setTimeout
          Ned Murphy Adobe Community Professional & MVP

          setInterval should work since it is documented to apply to Flash Player 6 (MX I believe).

           

          An alternative to relying on FPS, which is unreliable in a timeline setting, would be to use the getTimer function which dates back to Flash Player 4.  What that does is return the number of milliseconds that have elapsed since the swf started playing.  You can use it to set a start time and then check the difference with the current time until yourtime segment has passed (2000 msec?).

          • 2. Re: Creating a Timer w/o setInterval or setTimeout
            Jim Wiley Level 1

            Thanks Ned

            Unfortunately timers do not work. Deprecated away. AS1 or AS2. Flash player 6 or 7. Nothing works.

            I tried setInterval, getTimer and setTimeout.

            Jim

            • 3. Re: Creating a Timer w/o setInterval or setTimeout
              Rothrock Level 5

              Ned is correct and getTimer() is Flash 4 and setTimeout/setInterval is Flash 6 (also known as MX). So if you are implementing them correctly they should certainly run in a swf.

               

              If that swf doesn't behave wll in Authorware, then you need to nail down exactly what it will accept before you can come up with a solution.

               

              This little bit of code seems to work for me, but I don't have a Flash 6 plug-in sitting around to test it properly.

               

              var startTime=getTimer();

               

              setInterval(this,"test",1000);

               

              function test(){

              trace("Test: "+(getTimer()-startTime));

              startTime=getTimer();

              }

              • 4. Re: Creating a Timer w/o setInterval or setTimeout
                Jim Wiley Level 1

                Here is the rub. It does work, but not with Authorware or Director's old MX FlashAsset (DLL/Xtra).

                I have to incrementally step the back the FLA to use the Flash MX2004 to get a SWF output that will work.

                I am starting the process of building a Director 11.5 platform for my new UI. It doesn't fix the my need to replace the timer code in old movies I have to touch and rework (adding a new language or just making a correction).

                 

                This is why I need to try something different. I need to apply something like onEnterFrame() to the main timeline.

                 

                Any ideas? Otherwise I will have hundreds of timers to replace with additional frames and code.

                 

                Thanks again,

                Jim

                • 5. Re: Creating a Timer w/o setInterval or setTimeout
                  Ned Murphy Adobe Community Professional & MVP

                  onEnterFrame wasn't introduced until FP6 (MX), but if you can't get setInterval to work, or even getTimer, which is even older, then what are the chances that it will work?  You might get away with having a two framed movieclip that counts out frame changes, but as I said, relying on timeline FPS probably won't be very accurate.  If you are stuck using such old versions of other software, you might be stuck doing whatever it is you are trying to do whatever hard way you think might work.

                  • 6. Re: Creating a Timer w/o setInterval or setTimeout
                    Jim Wiley Level 1

                    Accuracy is not important.

                    Creating a relatave timedelay for the frame playing is important.

                     

                    1. create a two frame MC and give it a instance name.

                    2. have it increment a count going from frame to frame.

                    3. have the onEnterFrame test for the max cycles

                    4 delete the onEnterFrame

                    5. advance the main timeline

                     

                    Is this a rough outline?

                     

                    Thanks for your time y'all.

                    Jim

                    • 7. Re: Creating a Timer w/o setInterval or setTimeout
                      Rothrock Level 5

                      What do you mean you have to step back to use the Flash MX2004? If you have a newer version of Flash authoring environment you can use the publish options to target which version of Flash you are publishing for.

                       

                      And if you are using Flash MX2004, then that means you are publishing to Flash 7 and that would be why it isn't working. (Assuming that Director's old MX FlashAssets are MX related, which would be Flash 6.

                       

                       

                      As Ned pointed out, onEnterFrame was introduced in Flash 6, along with those other things (except getTimer() which was introduced in Flash 4) so if setInterval/setTimeout don't work then it won't work either.

                       

                       

                       

                      In any event you need to find out which version of plug-in/Flash player your authorware supports and then publish for that.

                      • 8. Re: Creating a Timer w/o setInterval or setTimeout
                        Jim Wiley Level 1

                        Hi,

                        They just changed the way they make SWF's. What they support and what they don't. After awhile they drop support for features - by design or not.

                        I have issues with the video too, but I can still encode it to an older format.

                        I am trying to by myself sometime. And keeping from working O/T too.

                         

                        I spend a large amount of time just fixing the files that have morphed with the upgrades of all my publishing and multimedia software I use. Oh yah, CAD software too.

                         

                        I am trying to work smarter, not harder.

                        Thanks again for your time.

                        Jim

                        • 9. Re: Creating a Timer w/o setInterval or setTimeout
                          Ned Murphy Adobe Community Professional & MVP

                          If you make a two frame movieclip you don't need to use onEnterFrame.  onEnterFrame is not what its name implies--it's more of a simulator of entering frames that usually only gets used in single frame scenarios.  By travelling from frame to frame in the movieclip you do what onEnterFrame would otherwise do in a single frame.

                           

                          So you just need to keep count in each frame (or just the second might suffice).

                          • 10. Re: Creating a Timer w/o setInterval or setTimeout
                            Jim Wiley Level 1

                            Ned was right the onEnterFrame method did not work as well in the old Authorware 7 (and Director MX too).

                            Thanks