dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Could I PLEASE get some help?

  1. #1
    Senior Member
    Join Date
    Feb 2001
    Posts
    124
    I'm trying to make an MC constantly oscillate from left to right and back again using actionscript instead of tweening.
    Well, so far I can get it to go to the right, but then the sucker just keeps on going; what can I do to make it pause & go to the left? the current code I've got written looks like I think it should look, but the MC doesn't go left, can anyone help me out?

    Frame 1:
    //---
    var nowTime = getTimer();
    var evalTime = (nowTime - clip.lastTime)/100;
    clip.lastTime = nowTime;

    var dif = (sumX - evalTime)/150;
    var maxX = 200;
    var minX = -200;
    var sumX = Math.abs(minX - maxX)

    if (clip._x <= minX) {
    clip._x += dif
    }else if (clip._x >= maxX){
    clip._x = clip._x}
    ---//


    Frame 2:
    //---
    gotoAndPlay(1)
    ---//

    ??????

    somebody get me back, thanks.

  2. #2
    Senior Member Leo Lima's Avatar
    Join Date
    Jul 2000
    Location
    São Paulo, Brazil
    Posts
    745
    this makes an mc go forth and back and so on till the sun goes nova in constant speed:
    Code:
    onClipEvent (load) {
      left_limit = 0;
      right_limit = 400;
      speed = 5;
      direction = 1; //left to right = 1, otherway = -1
    }
    
    onClipEvent (enterFrame) {
      this._x += direction * speed;
      if (direction > 0) {
        if (this._x > right_limit) {
          this._x = right_limit;
          direction = -1;
        }
      }
      else {
        if (this._x < left_limit) {
          this._x = left_limit;
          direction = 1;
        }
      }
    }
    Regards,
    Leo Lima
    [Edited by Leo Lima on 06-14-2001 at 06:43 PM]

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