...

View Full Version : buttons not directing to proper link



gilgalbiblewhee
05-13-2008, 11:20 PM
Can anyone tell me from reading this script why, by clicking the navigation buttons I 'm getting the previous link and not the actual link?


var soundStatus = true;
var mainSound = new Sound(_root.mcMainSound);
var clickMenu = new Sound();
var _click = new Sound();
_click.attachSound("click");
clickMenu.attachSound("clickMenu");
var totBut = 8;
var indexArr = new Array();
var linkPage = 1;
var pathMenu = _root._menu;
var pathFooter = _root.footer._menu;
var pages = _root.pages;
var footStartPos = 129;
var footEndPos = Stage.width - footer._width;
var pageStartPos = _root.pages._x;
var pageEndPos = footStartPos;
var isOpen = false;
var flagPress = true;
var flagMenuBar = true;
var lastRoll = pathMenu["btn" + Math.ceil(totBut / 2)];
var getHomePage = function ()
{
for (i = 1; i <= totBut; i++)
{
var _loc1 = pathMenu["btn" + i];
if (_loc1._index == 1)
{
return (_loc1);
} // end if
} // end of for
};
var hideMenu = function ()
{
for (i = 1; i <= totBut; i++)
{
pathMenu["btn" + i]._alpha = 0;
pathFooter["btn" + i]._alpha = 0;
} // end of for
};
var hideBar = function ()
{
pathMenu.menuBar._alpha = 0;
};
var showBar = function ()
{
pathMenu.menuBar._alpha = 100;
};
var moveBar = function (mcTarget, speed)
{
new mx.transitions.Tween(pathMenu.menuBar, "_y",

mx.transitions.easing.Strong.easeOut, pathMenu.menuBar._y,

mcTarget._y, speed, true);
};
var switcher = function (mcTarget, speed)
{
flagMenuBar = false;
hideMenu();
showBar();
roll(pathMenu["btn" + Math.ceil(totBut / 2)], 1);
var _loc1 = new mx.transitions.Tween(pathMenu.menuBar,

"_y", mx.transitions.easing.Strong.easeOut,

pathMenu.menuBar._y, mcTarget._y, speed, true);
_loc1.onMotionFinished = function ()
{
flagMenuBar = true;
hideBar();
roll(lastRoll, 1);
moveBar(lastRoll, 1.000000E-002);
};
};
var roll = function (mcTarget, speed)
{
var _loc1 = 100;
var _loc3 = 100;
new mx.transitions.Tween(mcTarget, "_alpha",

mx.transitions.easing.Strong.easeOut, mcTarget._alpha,

_loc1, speed, true);
new mx.transitions.Tween(pathFooter[mcTarget._name],

"_alpha", mx.transitions.easing.Strong.easeOut,

mcTarget._alpha, _loc1, speed, true);
for (i = mcTarget.pos + 1; i <= totBut; i++)
{
_loc1 = Math.round(_loc1 / 1.450000E+000);
new mx.transitions.Tween(pathMenu["btn" + i],

"_alpha", mx.transitions.easing.Strong.easeOut,

pathMenu["btn" + i]._alpha, _loc1, speed, true);
new mx.transitions.Tween(pathFooter["btn" + i],

"_alpha", mx.transitions.easing.Strong.easeOut,

pathFooter["btn" + i]._alpha, _loc1, speed, true);
} // end of for
for (i = mcTarget.pos - 1; i >= 1; i--)
{
_loc3 = Math.round(_loc3 / 1.450000E+000);
new mx.transitions.Tween(pathMenu["btn" + i],

"_alpha", mx.transitions.easing.Strong.easeOut,

pathMenu["btn" + i]._alpha, _loc3, speed, true);
new mx.transitions.Tween(pathFooter["btn" + i],

"_alpha", mx.transitions.easing.Strong.easeOut,

pathFooter["btn" + i]._alpha, _loc3, speed, true);
} // end of for
};
var checkText = function ()
{
if (pathMenu.menuText._y < 0)
{
pathMenu.menuText._y = pathMenu.menuText._y + 210;
} // end if
if (pathMenu.menuText._y > 180)
{
pathMenu.menuText._y = pathMenu.menuText._y - 210;
} // end if
};
var moveText = function (num)
{
var _loc1 = new mx.transitions.Tween(pathMenu.menuText,

"_y", mx.transitions.easing.Strong.easeOut,

pathMenu.menuText._y, pathMenu.menuText._y - num * 30, 1,

true);
Math.round(pathMenu.menuText._y);
checkText();
_loc1.onMotionFinished = function ()
{
Math.round(pathMenu.menuText._y);
checkText();
};
};
var buildIndexArr = function (num)
{
var _loc1 = new Object();
var _loc2 = num - Math.ceil(totBut / 2);
moveText(_loc2);
if (_loc2 != 0)
{
if (_loc2 > 0)
{
for (i = 0; i < _loc2; i++)
{
_loc1 = indexArr.shift();
indexArr.push(_loc1);
} // end of for
} // end if
if (_loc2 < 0)
{
for (i = 0; i < Math.abs(_loc2); i++)
{
_loc1 = indexArr.pop();
indexArr.unshift(_loc1);
} // end of for
} // end if
} // end if
};
var reWrite = function ()
{
for (i = 1; i <= totBut; i++)
{
var _loc1 = pathMenu["btn" + i];
_loc1._index = indexArr[i - 1];
} // end of for
};
var openPage = function (mcTarget)
{
linkPage = mcTarget._index;
pages.gotoAndStop(linkPage);
buildIndexArr(mcTarget.pos);
reWrite();
var _loc1 = new mx.transitions.Tween(footer, "_x",

mx.transitions.easing.Strong.easeOut, footStartPos,

footEndPos, 1, true);
new mx.transitions.Tween(pages, "_x",

mx.transitions.easing.Strong.easeOut, pageStartPos,

pageEndPos, 1, true);
flagPress = false;
pages.pageAnim.gotoAndPlay("start");
pageMask.gotoAndPlay("start");
footer.gotoAndPlay("start");
_loc1.onMotionFinished = function ()
{
isOpen = true;
};
};
var closePage = function (mcTarget)
{
linkPage = mcTarget._index;
buildIndexArr(mcTarget.pos);
reWrite();
var _loc1 = new mx.transitions.Tween(footer, "_x",

mx.transitions.easing.Strong.easeOut, footEndPos,

footStartPos, 1, true);
new mx.transitions.Tween(pages, "_x",

mx.transitions.easing.Strong.easeOut, pageEndPos,

pageStartPos, 1, true);
flagPress = false;
_loc1.onMotionFinished = function ()
{
isOpen = false;
flagPress = true;
pages.gotoAndStop(linkPage);
pageMask.gotoAndPlay(1);
};
};
var changePage = function (mcTarget)
{
var _loc1 = new mx.transitions.Tween(footer, "_x",

mx.transitions.easing.Strong.easeOut, footEndPos,

footStartPos, 1, true);
new mx.transitions.Tween(pages, "_x",

mx.transitions.easing.Strong.easeOut, pageEndPos,

pageStartPos, 1, true);
isOpen = false;
flagPress = false;
buildIndexArr(mcTarget.pos);
_loc1.onMotionFinished = function ()
{
linkPage = mcTarget._index;
pages.gotoAndStop(linkPage);
reWrite();
new mx.transitions.Tween(pages, "_x",

mx.transitions.easing.Strong.easeOut, pageStartPos,

pageEndPos, 1, true);
var _loc1 = new mx.transitions.Tween(footer, "_x",

mx.transitions.easing.Strong.easeOut, footStartPos,

footEndPos, 1, true);
flagPress = false;
pages.pageAnim.gotoAndPlay("start");
pageMask.gotoAndPlay("start");
footer.gotoAndPlay("start");
_loc1.onMotionFinished = function ()
{
isOpen = true;
};
};
};
for (i = 1; i <= totBut; i++)
{
var butName = pathMenu["btn" + i];
butName._index = i + Math.ceil(totBut / 2);
if (butName._index > totBut)
{
butName._index = butName._index - totBut;
} // end if
butName.pos = i;
indexArr.push(butName._index);
butName.onRollOver = butName.onReleaseOutside =

function ()
{
lastRoll = this;
if (flagMenuBar)
{
moveBar(this, 1.000000E-002);
roll(this, 1);
clickMenu.start();
} // end if
};
butName.onRollOut = function ()
{
lastRoll = pathMenu["btn" + Math.ceil(totBut / 2)];
if (flagMenuBar)
{
roll(pathMenu["btn" + Math.ceil(totBut / 2)],

1);
moveBar(pathMenu["btn" + Math.ceil(totBut /

2)], 1.000000E-002);
} // end if
};
butName.onRelease = function ()
{
if (flagPress)
{
if (!isOpen)
{
if (this._index != 1)
{
openPage(this);
switcher(pathMenu["btn" +

Math.ceil(totBut / 2)], 1);
}
else if (linkPage != 1)
{
linkPage = 1;
pages.gotoAndStop(linkPage);
buildIndexArr(this.pos);
reWrite();
switcher(pathMenu["btn" +

Math.ceil(totBut / 2)], 1);
} // end else if
}
else if (this._index == 1 || this._index ==

linkPage)
{
closePage(this);
switcher(pathMenu["btn" + Math.ceil(totBut

/ 2)], 1);
}
else
{
changePage(this);
switcher(pathMenu["btn" + Math.ceil(totBut

/ 2)], 1);
} // end else if
} // end else if
};
} // end of for
pathMenu.menuBar.setMask(pathMenu.barMask);
pathMenu.menuText.setMask(pathMenu.textMask);
pages.setMask(pageMask);
hideBar();
roll(pathMenu["btn" + Math.ceil(totBut / 2)],

1.000000E-002);
checkText();

I tried uploading the swf file but it didn't work.

gnomeontherun
05-14-2008, 06:40 AM
Umm I'm going to need to see this in action. Can you post the swf on a fileshare site and link to it?

I'm just not sure I can understand the code as written without the visual help. Actually can you post the FLA with it in a zip?

Lithen
05-23-2008, 07:38 AM
While your at it, i have a simple question!

Im making my main content in flash for a website
and i want some buttons in Scene1,Frame1 to link to about 4 diffrent Movieclips and in those Movieclips, a BACK button so i can return to Scene1,Frame1

How would i script that?
I have failed so far and i cant find any good tutorials for it, they all show how to link to URL's

Many thanks in advance!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum