(AS3) Change Focus to Specified Movie Clip

Posted: April 5, 2011 in Flash / Actionscript 3, Game Programming
Tags: , , ,

I want to give a simple trick about how to change focus to specified movie clip. You may have problem with keyboard input when your movie clip are closed/unclosed by other movie clip, your movie clip don’t want to receive keyboard press event until you clik on your application window.

Here’s the trick :

this.stage.focus = mc;

mc is movie clip that you desired to receive keyboard event. I found there’s a problem remain. With code above maybe you’ll encountered annoying focus rectangle diplay. Usually this focus rectangle appear as yellow lines surrounding your movie clip.

To remove this annoying yellow lines, you should add another line like below:

this.stage.focus = mc;
mc.focusRect = false;

Problem solved :)

  1. Alexa says:

    Cool. Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s