This is the code in my movie that I'm using as a secondary way to navigate through a site.
I rolled out the joomla template on a single page, and it worked perfectly. When I however rolled it out to the rest of the site, the buttons all pointed to the same page. Nothing was changed.
Is it my crappy coding or is something else interfering with the code?
stop(); speed = 10; initial_width = 75; target_width = 450; sp = rect1._x; this.createEmptyMovieClip("emptymc", 0); emptymc.onEnterFrame = function() { for (i=1; i<=6; i++) { if (_root.hit.hitTest(_root._xmouse, _root._ymouse, true)) { if (_root["rect"+i].hitTest(_root._xmouse, _root._ymouse, true)) { new_x = (_root.sp-(75(i-1)))-rect1._x; rect1._x += new_x/speed; n_width = target_width-_root["rect"+i]._width; _root["rect"+i]._width += n_width/speed; } else { n_width2 = initial_width-_root["rect"+i]._width; _root["rect"+i]._width += n_width2/speed; } } else { new_x = _root.sp-rect1._x; rect1._x += new_x/(speed+50); n_width2 = initial_width-_root["rect"+i]._width; _root["rect"+i]._width += n_width2/(speed-1); } _root["rect"+(i+1)]._x = _root["rect"+i]._x+_root["rect"+i]._width; _root["movie"+i]._x = _root["rect"+i]._x-1; } }; / GetURL FIX */ var swfUrl:String = _root._url; var lastSlashIndex:Number = swfUrl.lastIndexOf("/"); var pipeIndex:Number = swfUrl.indexOf("|"); var baseUrl:String; if (pipeIndex >= 0) { baseUrl = swfUrl.substring(0, pipeIndex); baseUrl += ":"; } else { baseUrl = ""; } baseUrl += swfUrl.substring(pipeIndex + 1, lastSlashIndex + 1);
/* Button Actions */
movie1.onMouseUp = function() { getURL("index.php?option=com_content&task=blogcategory&id=38&Itemid=95"); } movie2.onMouseUp = function() { getURL("index.php?option=com_content&task=blogcategory&id=34&Itemid=99"); } movie3.onMouseUp = function() { getURL("index.php?option=com_content&task=blogcategory&id=37&Itemid=96"); } movie4.onMouseUp = function() { getURL("index.php?option=com_content&task=view&id=45&Itemid=93"); } movie5.onMouseUp = function() { getURL("index.php?option=com_content&task=blogcategory&id=40&Itemid=100"); } movie6.onMouseUp = function() { getURL("index.php?option=com_content&task=view&id=44&Itemid=92"); }
Not sure, maybe someone else knows, but there is one bit of code that you need to change it is wasting flash processing and is hard to read, something I like to do is short cuts but maybe it is just me, but something like...
var rect: MovieClip; var rect1: MovieClip; var xmouse: Number = _root._xmouse; var ymouse: Number = _root._ymouse; var hit: MovieClip = _root.hit;
for( i = 1; i < 7; i++ ) {
rect = _root["rect"+i]; rect1 = _root["rect"+(i+1)];
if ( hit.hitTest( xmouse, ymouse, true ) ) { if( rect.hitTest( xmouse, ymouse, true ) ) {
new_x = (_root.sp-(75*(i-1)))-rect1._x;
rect1._x += new_x/speed;
n_width = target_width - rect._width;
rect._width += n_width/speed;
}
else
{
n_width2 = initial_width - rect._width;
rect._width += n_width2/speed;
}
} else {
new_x = _root.sp-rect1._x;
rect1._x += new_x/(speed+50);
n_width2 = initial_width - rect._width;
rect._width += n_width2/(speed-1);
}
rect1._x = rect._x + rect._width; _root["movie"+i]._x = rect._x-1;
}
But you might want to avoid getURL and pass the data to javascript to load.
onMouseUp is a mouse listen event.
My guess is it was only going to the last link specified.
change each to:
movie6.onRelease = function() {
getURL("index.php?option=com_content&task=view&id=44&Itemid=92");
}
etc.
Thanks Persist.