how to handle _root with mutliple swf

I was working to create a  flash-based football game application.  Inside the game, a football player moves in various direction when I press the arrow keys. However, it was not working fine after I dd some changes.

The code of football player goes like this.

function step(who) {
	//check to see if the football player in question is controlled by the player or by the computer
	if (_root["football"+who].code == "player") {

It looked like a decent piece of code until I added some other features. The problem is I was loading some other .swf after loading this .swf. As a result, _root gets changed everytime a new movie is loaded. _root always point to latest .swf unless _lockroot is true.

this._lockroot = true;

Using the below code, I was able to ensure that the given .swf will be treated as root.

  onClipEvent (load)
    this._lockroot = true;
  game_mc.loadMovie ("football.swf");

Leave a Reply

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

You are commenting using your 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