0

How can I ensure that the ThrottleEvent is supported by the current used browser?

I can see that they mention some browsers which support it:

The platforms that support throttling and pausing are currently the following: Flash Player Desktop Mac and Windows, AIR Mobile, and Flash Player Android. The following platforms do not dispatch the ThrottleEvent automatically because they do not yet support pausing or throttling: AIR for TV devices, AIR for desktop, and Flash Player Linux Desktop.

But I don't think that I can check specifically for each one of them (I guess there are edge cases too).

I'd like to do something like this:

package
{
    import flash.display.MovieClip;
    import flash.external.ExternalInterface;
    import flash.events.ThrottleEvent;
    import flash.events.ThrottleType;

    public class TestThrottle extends MovieClip
    {
        public function TestThrottle()
        {
            var throttlingIsEnabled = ???
            ExternalInterface.call('throttlingSupported', throttlingIsEnabled);
        }
    }
}

Do you know a way how I could achieve this?

dan-lee
  • 14,365
  • 5
  • 52
  • 77
  • Why do you want to know if throttling is supported? Since it's a performance optimization, is there a problem with coding for it for any case where it's supported, and cases where it's not supported there's no difference anyway? – Aaron Beall Mar 11 '15 at 15:01
  • @Aaron It's directly connected to my other question: http://stackoverflow.com/questions/28853243/start-pause-timer-in-movieclip-when-in-viewport. It kinda works for my other question, but only in supported browsers. – dan-lee Mar 11 '15 at 15:05
  • Ok. I posted an answer in that thread to that problem. In this case, I don't think checking if throttling is supported is necessary. Just code for it, and if it's not there it's not there. – Aaron Beall Mar 11 '15 at 15:56

1 Answers1

0

As you mentioned in your question :

The platforms that support throttling and pausing are currently the following: Flash Player Desktop Mac and Windows, AIR Mobile, and Flash Player Android. ...

And as you are writing for Flash Player, so you have just to verify if it's Flash Player Desktop Mac or Windows to know if throttling and pausing are supported, and you can verify that using flash.system.Capabilities especially Capabilities.version, Capabilities.os and Capabilities.playerType.

Hope that can help.

akmozo
  • 9,829
  • 3
  • 28
  • 44
  • Thanks, I think I have to check for them individually. I didn't know about the `Capabilities`. This makes it easy to check :) – dan-lee Mar 11 '15 at 15:43
  • I still am not sure why you have to check. If you code for it, it will work when it's there. If it's not there, it's just a performance optimization you don't get. It's generally not a good idea to code against `Capabilities` unless there's an actual critical bug and that's the only way you can determine the bug exists (that's very rare in my experience), otherwise if your logic is wrong or the conditions change (browser/player updates, etc) your logic will break and possibly do more harm than good. – Aaron Beall Mar 11 '15 at 15:53