A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: smoothness

Hybrid View

  1. #1
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    I think you're asking if you can use it on a script which is on the main timeline. Yes you can. Let's say there is a movieclip called 'mc'. Here is a more fleshed out version of that script.

    code:

    mc.target = 200;
    mc.speed = 2;

    mc.onEnterFrame = function()
    {
    var dx = this.target - this._x;
    if (Math.round(dx) == 0)
    {
    this._x = this.target;
    delete this.onEnterFrame;
    }
    else {
    this._x += dx / this.speed;
    }
    }


  2. #2
    Member
    Join Date
    Nov 2003
    Posts
    88
    what if I wanted this MC to move at a steady pace,
    then once it reached its destination ..
    maybe faded out? .. or start back at the begining?
    is that possible?

    thanks,
    -dan

    Quote Originally Posted by jbum
    I think you're asking if you can use it on a script which is on the main timeline. Yes you can. Let's say there is a movieclip called 'mc'. Here is a more fleshed out version of that script.

    code:

    mc.target = 200;
    mc.speed = 2;

    mc.onEnterFrame = function()
    {
    var dx = this.target - this._x;
    if (Math.round(dx) == 0)
    {
    this._x = this.target;
    delete this.onEnterFrame;
    }
    else {
    this._x += dx / this.speed;
    }
    }


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