1

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");
    };
}
POSIX_ME_HARDER
  • 772
  • 9
  • 22
noobug
  • 953
  • 1
  • 7
  • 11
  • Is there some code missing? It just trails off after 'while (counter' – Richard Inglis Mar 07 '10 at 14:49
  • Hi Richard, many thanks for reply. It seems that I can't put all the code in one go, so after that it is – noobug Mar 07 '10 at 18:29
  • 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 – noobug Mar 07 '10 at 18:30
  • for (var i = 0; i<9; i++) { _root["btn_what_"+i].onRelease = function() { SWFAddress.setValue("/what-we-do/"); }; } – noobug Mar 07 '10 at 18:31
  • And more of the above modified to each button. Any help much appreciated! Thank you. – noobug Mar 07 '10 at 18:32
  • Thanks, but it's still hard to read all on one line... Maybe best if you can EDIT your question to show all the code, with each statement on it's own line, so we can read it more easily. Indent each line with 4 spaces to make it show as code on the page. This will make it easier for people to help you! :) – Richard Inglis Mar 08 '10 at 10:50
  • What is it that doesn't work here, the button event or the call to SWFAddress? Have you tried putting traces in the button release handlers to ensure they're receiving mouse interaction? – shanethehat Jul 28 '11 at 22:50

0 Answers0