Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Make a Dynamic Tween

    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:

    Code:
    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?

  • #2
    New Coder
    Join Date
    Feb 2006
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nevermind,

    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:

    Code:
    Graphic1._x = xposition;
    Graphic1._y = yposition:
    
    var i:Number = xposition;
    
    if(i>0){
    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.

    Thanks,
    pspsully
    Last edited by pspsully; 03-30-2009 at 12:12 PM.

  • #3
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Or use the Tween Class.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •