Skip to main content
Inspiring
September 15, 2011
Answered

Creating a Timer w/o setInterval or setTimeout

  • September 15, 2011
  • 1 reply
  • 1795 views

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

This topic has been closed for replies.
Correct answer Ned Murphy

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


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.

1 reply

Ned Murphy
Legend
September 15, 2011

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?).

Jim WileyAuthor
Inspiring
September 15, 2011

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

Inspiring
September 15, 2011

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();

}