Help with movie via actionscript
oki - kinda new flash. find pieces of actionscripts other people made can use... (like alot of other people guess)
i found function can move af movieclip on point of another...
_global.movecontent = function (targetmc, thefriction, theratio, toscale, newxpos, newypos, whendone)
{
targetmc.onenterframe = null;
var friction = thefriction;
var ratio = theratio;
var speedy = 0;
var speedx = 0;
var speedscale = 1;
var scaledone = false;
var xposdone = false;
var yposdone = false;
trace(targetmc._y); // output _y check incorrect movement
targetmc.onenterframe = function ()
{
var _loc4 = newxpos - this._x;
speedx = speedx * friction + (newxpos - this._x) * ratio;
this._x = this._x + math.round(speedx);
var _loc3 = newypos - this._y;
speedy = speedy * friction + (newypos - this._y) * ratio;
this._y = this._y + math.round(speedy);
var _loc2 = toscale - this._xscale;
speedscale = speedscale * friction + (toscale - this._xscale) * ratio;
this._xscale = this._xscale + math.round(speedscale);
this._yscale = this._yscale + math.round(speedscale);
if (_loc3 == 0)
{
this._y = newypos;
yposdone = true;
} // end if
if (_loc4 == 0)
{
this._x = newxpos;
xposdone = true;
} // end if
if (_loc2 == 0)
{
this._xscale = toscale;
this._yscale = toscale;
scaledone = true;
} // end if
if (scaledone && xposdone && yposdone)
{
whendone();
this.onenterframe = null;
} // end if
};
};
and works excellent.... allmost... using move movieclips , down (y coordinate) only, when set theratio variabel low, 0.2 not accurate, when use move moveclip 100px down , 100px after couple of moves movieclip have changed position 1-3 px.
i can't figured out math in function, maybe in here can tell me if possible make more accurate, shift not accure?
i use move temp_mc:
down:
_global.movecontent (temp_mc, 0,0.2, 100, temp_mc._x, temp_mc._y+100, null);
and up:
_global.movecontent (temp_mc, 0,0.2, 100, temp_mc._x, temp_mc._y+100, null);
maybe math.round not accurate or ??
any suggestions?
kind regards
mr. morton
i found function can move af movieclip on point of another...
_global.movecontent = function (targetmc, thefriction, theratio, toscale, newxpos, newypos, whendone)
{
targetmc.onenterframe = null;
var friction = thefriction;
var ratio = theratio;
var speedy = 0;
var speedx = 0;
var speedscale = 1;
var scaledone = false;
var xposdone = false;
var yposdone = false;
trace(targetmc._y); // output _y check incorrect movement
targetmc.onenterframe = function ()
{
var _loc4 = newxpos - this._x;
speedx = speedx * friction + (newxpos - this._x) * ratio;
this._x = this._x + math.round(speedx);
var _loc3 = newypos - this._y;
speedy = speedy * friction + (newypos - this._y) * ratio;
this._y = this._y + math.round(speedy);
var _loc2 = toscale - this._xscale;
speedscale = speedscale * friction + (toscale - this._xscale) * ratio;
this._xscale = this._xscale + math.round(speedscale);
this._yscale = this._yscale + math.round(speedscale);
if (_loc3 == 0)
{
this._y = newypos;
yposdone = true;
} // end if
if (_loc4 == 0)
{
this._x = newxpos;
xposdone = true;
} // end if
if (_loc2 == 0)
{
this._xscale = toscale;
this._yscale = toscale;
scaledone = true;
} // end if
if (scaledone && xposdone && yposdone)
{
whendone();
this.onenterframe = null;
} // end if
};
};
and works excellent.... allmost... using move movieclips , down (y coordinate) only, when set theratio variabel low, 0.2 not accurate, when use move moveclip 100px down , 100px after couple of moves movieclip have changed position 1-3 px.
i can't figured out math in function, maybe in here can tell me if possible make more accurate, shift not accure?
i use move temp_mc:
down:
_global.movecontent (temp_mc, 0,0.2, 100, temp_mc._x, temp_mc._y+100, null);
and up:
_global.movecontent (temp_mc, 0,0.2, 100, temp_mc._x, temp_mc._y+100, null);
maybe math.round not accurate or ??
any suggestions?
kind regards
mr. morton
More discussions in ActionScript 1 and 2
adobe
Comments
Post a Comment