0

I have this page and I am trying to link to the /our-other-brands page and i have this actionscript code. All the links are working but the our other brands in the top nav...here is the line i cant seem to understand what its doing

var sectionName:String = me.currentTarget.name.substr(0, -6);

Here is all the code from the function below

// navigation button pressed
function navButtonPress(me:MouseEvent):void {
    var sectionName:String = me.currentTarget.name.substr(0, -6);
    trace(sectionName + ' button press');

    // jump to section
    switch(sectionName) {
        case 'home':
            navigateToURL(new URLRequest('/'), "_self");
            break;
        case 'products':
            navigateToURL(new URLRequest('/petmate-products'), "_self");
            break;
        case 'our':
            navigateToURL(new URLRequest('/our-other-brands'), "_self");
            break;          
        case 'tips':
            navigateToURL(new URLRequest('/category/tips-from-the-expert'), "_self");
            break;
        case 'news':
            navigateToURL(new URLRequest('/news-press'), "_self");
            break;
        case 'about':
            navigateToURL(new URLRequest('/about-petmate'), "_self");
            break;
        case 'retailers':
            navigateToURL(new URLRequest('http://retail.petmate.com'), "_self");
            break;
    }
    }

If anyone has any idea why the link is not working i would highly appreciate any help.

Anne
  • 26,765
  • 9
  • 65
  • 71
Matt Elhotiby
  • 43,028
  • 85
  • 218
  • 321

2 Answers2

1

It appears to be finding the name of the button that was pressed and removing the final six charachters from the end.

So if you have a button named "homeButton", it takes the last six charachters off the end and uses them in the switch statement. So homeButton becomes home etc.

If this isn't what your asking then can you clarify the request?

Wes
  • 6,697
  • 6
  • 34
  • 59
  • You could add a trace in trace(me.currentTarget.name); BTW the assumption is that its appended with button. The trace if you run in debug will show what the currentTarget name was. – Wes May 14 '11 at 21:56
  • @tamer I'm not sure to be honest. I run this type of stuff in flash builder (using the flex framework) I just hit the debug button. I don't think you can debug release code as the debug symbols will be removed. You have access to the source code do you have no way of executing that code? – Wes May 14 '11 at 22:00
  • i got it figured out...thanks again...one last thing...if you go the the link in my question...you can see that all is well other then when i click on the link it doesnt stay open link the rest ...any ideas – Matt Elhotiby May 14 '11 at 22:16
1

It's taking whatever the 'currentName' is of the me object, and returning that name with the last 6 characters removed.

e.g. if currentName is 'abcdefghi', then that will return 'abc'

Marc B
  • 356,200
  • 43
  • 426
  • 500