all groups > flash actionscript > march 2006 >
You're in the

flash actionscript

group:

Padding in movie_clip._width after using Tween


Padding in movie_clip._width after using Tween Rev_Shabbazz
3/16/2006 11:07:54 PM
flash actionscript:
Hello All,

I am using Flash 8 Professional for a real-world pop-up application. I have
isolated a tweening problem that I can not seem to fix and I need to call in
the experts. I have created a very small sample app which demonstrates my
problem.

My stage is 500 x 500.

I've got a movie clip called my_mc which contains a 50 x 50 square. On the
stage, it is located in the lower left-hand corner (the box is registered in
the lower left corner as well).

I've got two other movie clips called findedgex and findedgey. They consist
of a vertical line and a horizontal line respetively. They will be dynamically
positioned to the top edge (findedgey) and right edge (findedgex) of the box
after a tween has been applied to it.

When I roll over the my_mc movieclip, I am tweening it to a random height and
width and then repositioning the findedgex and findedgey lines accordingly.

Am am making the following assumptions ::
The line corresponding to the top edge of the box = my_mc._y - my_mc._height
The line corresponding to the right edge of the box = my_mc._x - my_mc._width

The problem I am having is this -- the width and height properties of my_mc
contain a level of error after the tween has been applied. The greater the
distance of the tween, the greater the level of error. This makes positioning
elements to the top-right corner of the box (ie, a close "X" button) nearly
impossible.

The code for my sample application is as follows ::

========================================

import mx.transitions.Tween;
import mx.transitions.easing.*;

my_mc.onRollOver = function():Void
{
tmpTween = new Tween( my_mc, "_width", None.easeNone, 50, 50+random(400), 6,
false );
tmpTween.onMotionFinished = function()
{
findedgex._x = my_mc._x + my_mc._width;
}
tmpTween = new Tween( my_mc, "_height", None.easeNone, 50, 50+random(400), 6,
false );
tmpTween.onMotionFinished = function()
{
findedgey._y = my_mc._y - my_mc._height;
}
}

my_mc.onRollOut = function():Void
{
tmpTween = new Tween( my_mc, "_width", Strong.easeOut, my_mc._width, 50, 6,
false );
tmpTween.onMotionFinished = function()
{
findedgex._x = my_mc._x + my_mc._width;
}
tmpTween = new Tween( my_mc, "_height", Strong.easeOut, my_mc._height, 50, 6,
false );
tmpTween.onMotionFinished = function()
{
findedgey._y = my_mc._y - my_mc._height;
}

}

findedgex._x = my_mc._x + my_mc._width;
findedgey._y = my_mc._y - my_mc._height;

=============================================

1) Is this a problem with my code or with the Tween class? (I have tried
various easings and they all yeild the same error-result)
2) Any ideas how I can counteract (ie hack) the problem away?

Thanks in advance for your help!
-Tim

Re: Padding in movie_clip._width after using Tween Rev_Shabbazz
3/17/2006 7:20:10 PM
Re: Padding in movie_clip._width after using Tween Rev_Shabbazz
3/20/2006 5:58:24 PM
Anyone? Anyone?

AddThis Social Bookmark Button