Flash AS snippet is no use for my case
Posted: Thu Apr 03, 2008 3:15 am
A friend shared an AS snippet with me for a banner I want to make. It slides 3 movieclips called "tab" (tab0,tab1,tab2,tab3) along the side when you rollover on each. However I need more than 3 movieclips, but when I created a new one and named it tab4, the script stopped working.
Use this code at the first frame:
I tried changing:
ind = this._name.substr(3, 1);
to:
ind = this._name.substr(4, 1);
but still it doesn't work.
Use this code at the first frame:
Code: Select all
stop ();
state = new Array(false, false, false, false);
media = Stage.width / (state.length + 10);
minimum = (Stage.width - tab0._width) / (state.length - 1);
maximum = tab0._width;
MovieClip.prototype.move = function (goal, speed)
{
var _loc1 = this;
_loc1.arrive = false;
_loc1.onEnterFrame = function ()
{
var _loc1 = this;
_loc1._x = (goal - _loc1._x) / speed + _loc1._x;
if (Math.abs(goal - _loc1._x) <= 5.000000E-001)
{
_loc1._x = goal;
_loc1.arrive = true;
delete _loc1.onEnterFrame;
} // end if
};
};
for (i = 0; i < state.length; i++)
{
this["tab" + i].onRollOver = function ()
{
ind = this._name.substr(3, 1);
state[ind] = true;
};
this["tab" + i].onRollOut = function ()
{
ind = this._name.substr(3, 1);
state[ind] = false;
};
} // end of for
heads = function ()
{
result = -1;
for (i = 0; i < state.length; i++)
{
if (state[i])
{
result = i;
} // end if
} // end of for
return (result);
};
_root.onEnterFrame = function ()
{
var _loc1 = this;
heads_hnd = heads();
if (heads_hnd != -1)
{
for (z = 0; z < state.length; z++)
{
if (z <= heads_hnd)
{
_loc1["tab" + z].move(z * minimum, 20);
continue;
} // end if
_loc1["tab" + z].move(z * minimum + maximum - minimum, 20);
} // end of for
return;
} // end if
for (z = 0; z < state.length; z++)
{
_loc1["tab" + z].move(z * media, 10);
} // end of for
};
ind = this._name.substr(3, 1);
to:
ind = this._name.substr(4, 1);
but still it doesn't work.