I used this code for another site and it worked fine, but now I have modified it for a new site and no buttons work whatsoever. I am still new to this so I am probably missing something simple.
I have given each navigation button an instance name ie. btn_X_0, _1, etc. For some frames, more than one type of button lead to these, so I have labelled the relevant buttons btn_contact1, 2 etc. On the timeline I have labelled relevant frames with the $ sign for SWFAddress.
I have my swfaddress script in the same folder as the fla.
Here is my code - help would be much appreciated!
import SWFAddress;
stop();
/*
_root.onEnterFrame = function() {
*/
String.prototype.searchreplace = function(find, replace) {
var string = this;
var counter;
while (counter<string.length) {
var start = string.indexOf(find, counter);
if (start == -1) {
break;
} else {
var before = string.substr(0, start);
var after = string.substr(start+find.length, string.length);
string = before+replace+after;
var counter = before.length+replace.length;
}
}
return string;
};
// SWFAddress handling
SWFAddress.onChange = function() {
var value = SWFAddress.getValue();
//trace(value);
var frame = _currentframe;
gotoAndStop('$'+value);
if (frame == _currentframe) {
gotoAndStop('$/error/');
}
var title = 'Site';
var names = SWFAddress.getPathNames();
for (var i = 0; i<names.length; i++) {
title += ' / '+names[i].substr(0, 1).toUpperCase()+names[i].substr(1);
}
title = title.split("-").join(" ");
SWFAddress.setTitle(title);
for (var i = 0; i<9; i++) {
_root["btn_home_"+i].onRelease = function() {
SWFAddress.setValue("/");
};
}
for (var i = 0; i<9; i++) {
_root["btn_what_"+i].onRelease = function() {
SWFAddress.setValue("/What-We-Do/");
};
}
for (var i = 0; i<9; i++) {
_root["btn_five_"+i].onRelease = function() {
SWFAddress.setValue("/How-We-Work/5-Facts");
};
}
for (var i = 0; i<9; i++) {
_root["btn_five1_"+i].onRelease = function() {
SWFAddress.setValue("/How-We-Work/5-Facts");
};
}