[FMX]Substract part of instance name in function

Hi everybody,

I have the following code from a tutorial on Kirupa:

_root.currMovie = "home";
container.loadMovie(_root.currMovie+".swf");
_root.home.gotoAndStop(2)
newThis=home
MovieClip.prototype.Pressed = function() {
this.onPress = function() {
if (_root.currMovie == undefined) {
_root.currMovie = this._name;
_root.container.loadMovie(this._name+".swf");
} else if (_root.currMovie != this._name) {
if (_root.container._currentframe>=_root.container.midframe) {
	_root.currMovie = this._name;
	_root.container.play();
}
}
newThis = this;
_global.oldThis.play();
this.gotoAndStop(2);
};
};
_root.home.Pressed();
_root.about.Pressed();
_root.service.Pressed();
_root.contact.Pressed();

It is used to make transitions between different swf’s. My question i about the laodMovie part.

[color=red]_root.container.loadMovie(this._name+".swf");[/color]

As you can see are the button names: home, about, service and contact. This are also the names of the external swf’s. But now I have chanced my button names in: [color=red]btn_home, btn_about, etc[/color]. Now is it a little stange to name my external swf’s btn_home etc, so how can I substract the prefix [color=red]btn_[/color] from the buttons so that the externa swf’s can keep their normal names? I know it has something to do with substr but I don’t know how and where to implement it.

Anybody with an answer?
Thanks in advance

Why you added the prefix to the buttons :puzzle:

To control the over, out and release state of the buttons with a [color=blue]for in[/color] loop :slight_smile:

Maybe that the next explenation is a bit clearer. I have 6 buttons on the main stage: (btn_home, btn_about, …btn_contact) and I have an equal amount of external movies to load in a container on the stage (name container) I have the following function to control the buttons and to load the external movies:

for (var i in this) {
 if (this*._name.substr(0, 4) == "btn_") {
  setButton(this*._name);
 }
}
function setButton(clip) {
 var clip = eval(clip);
 clip.onRelease = function() {
  if (_root.currMovie == undefined) {
   [color=red]_root.currMovie = this._name;[/color]
[color=blue]// I tried _root.currMovie = this._name.substr(4);[/color][color=#ff0000]
[/color]   this._parent.container.loadMovie(this._name+".swf");
  } else if (_root.currMovie != this._name) {
   if (this._parent.container._currentframe>=this._parent.container.midframe) {
	_root.currMovie = this._name;
[color=#0000ff]// I tried _root.currMovie = this._name.substr(4);[/color]
	this._parent.container.play();
   }
  }
 };
}

When I press one of the buttons, i get the following error:

[color=red]Error opening URL “[/color][[color=red]file:btn_homede.swf[/color]](file:///D|/Lamai%20Motor%20Land/btn_homede.swf)[color=red]”[/color]
[color=#ff0000][/color]
[color=black]I tried to add a substr(4) to parts marked red in the function, but without result. What am I doing wrong?[/color]

Thanks in advance