News

Currentframe

This is still sort of AS2 I'm not sure the syntax translation to AS3 but the same principles can apply.

NEVER UNDERESTIMATE THE POWER OF _currentframe

This really saves a lot of coding, it's not always efficient or practical for something complicated, but if you're in a rush or need to make a work around for a bug then this is a huge solution for doing things.

For example if you want a door to unlock when a key is touched. Simply make the key disappear on the 2nd frame by deleting it and have the door check if the key is now on frame 2.

You can make nearly any action happen this way. Hit tests can be combined with what frame the character is on as well to solve problems.

I tend to make the movieclip do something on the 2nd frame then just refer to that with _currentframe whenever it starts to do something.

I use this a lot for cutting down complicated code in half the time. Very useful.

Permalink Posted in Game Making by Eggy on Apr 20, 2013