Reputation: 44066
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.
Upvotes: 0
Views: 93
Reputation: 360572
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'
Upvotes: 1
Reputation: 7047
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?
Upvotes: 1