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.
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]