Tag Archives: coding

Flixel and Tweensy Working Together

Are you using Flixel for Flash development? You should be.

Are you using Tweensy for easy programmatic Flash tweening? You should be.

Did you know that when Flixel loses focus and pauses, Tweensy doesn’t automatically pause? You should. It can cause some weird behavior.

I’ve figured out a simple fix that pauses Tweensy when Flixel doesn’t have focus. I just did it, so be aware that there may be some unexpected consequences of this that I don’t know about.

Put the following in your main class that extends FlxGame:

override protected function onFocus(FlashEvent:Event = null):void

override protected function onFocusLost(FlashEvent:Event = null):void

And that’s that. When Flixel pauses due to lost focus, Tweensy will as well, and when Flixel resumes, so will Tweensy. Just make sure you don’t get the “pause” and “resume” flipped; I did at first, and I couldn’t figure out what the hell was wrong.