View Full Version : Make a Dynamic Tween

03-30-2009, 11:04 AM
Hi Guys,

I've been playing around with this for a few days now but cant figure it out.
Basically i have a Graphic that i am moving from point A to point B.

Point b will always be the position 0,0 however point A will change dynamically depending on the positions passed through to it.

i can successfully pass the positions through to the Frame with the tween but i cant get it to work.

I have tried converting the graphic to a Movie Clip in frame one of the tween and the same on the last frame, i have given them 2 separate names, say Graphic1 and Graphic2.

The i have tried setting their positions as follows:

Graphic1._x = xposition;
Graphic1._y = yposition;
Graphic2._x = 0;
Graphic2._y = 0;

This works in that it puts the graphics in the position i want them, but the tween does not work :(

Has anyone ideas?

03-30-2009, 12:09 PM

I just figured out that flash cannot handle Clip Events with mixed in AS at the same time, it will prioritize AS over the Clip.

The solution was to write the tween in AS, is looks something like this:

Graphic1._x = xposition;
Graphic1._y = yposition:

var i:Number = xposition;

i = i - 10;
Graphic1._x +=-10;

Basically the above is fine for what i wanted, it moves the Graphic1 Movie clip from right to left by 10px every frame until it hits 0 on the x axis.

It would have a problem if the x position origianal passed was not an exact divisional of 10, it would go slightly off screen, to fix that, i have changed the if(i>0){ line to if(i>10){. The after that has run i tell it to position it to 0.


03-30-2009, 12:30 PM
Or use the Tween Class (http://www.kirupa.com/developer/actionscript/tween.htm).