A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Can I make my movieclip wait?

  1. #1
    Member
    Join Date
    Jun 2004
    Location
    Ypsilanti, MI
    Posts
    37

    Can I make my movieclip wait?

    I have an action that when a movieclip is clicked it is supposed to move to the top left of the screen. I have a FOR statement that is supposed to move it there in ten intervals, but the movieclip seems to jump right to the top left. Can I make each For loop pause for a small increment before it executes the next loop to make the movieclip appear to move to the top instead of jump?





    var x:Number=movieClip._x;
    var newx:Number=x/10;
    var y:Number=movieClip._y;
    var newy:Number=y/10;


    for (var i:Number = 1; i<11; i++) {

    x=(x-newx) ;
    movieClip._x=x;


    y=(y-newy) ;
    movieClip._y=y;



    }

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Generally the for loops execute so quickly that you do not get the transition effect. Look into the tween class:
    http://www.macromedia.com/devnet/fla...eening_05.html
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    or use an onEnterFrame event -
    Code:
    onEnterFrame = function(){
    movieClip._x-=10;
    movieClip._y-=10;
    movieClip._y<100 ? onEnterFrame = null : null;
    };

  4. #4
    Member
    Join Date
    Jun 2004
    Location
    Ypsilanti, MI
    Posts
    37
    It still jumps right to the spot no matter what duration I specify.

  5. #5
    Member
    Join Date
    Jun 2004
    Location
    Ypsilanti, MI
    Posts
    37
    Got it to work...Thanks

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center