Shift movie clips _x position back and forth?

  • RockmanTV
  • Proficient
  • Proficient
  • RockmanTV
  • Posts: 348

Post 3+ Months Ago

I have a movie clip that I have slowly moving up (by reducing the _y position onenterFrame). I also want to shift this movie back and forth + or - 10 pixels or so. I haven't been able to find an effective way to do this. I've tried using setInterval but it's giving me problems and not working as expected. Any ideas?

Code: [ Select ]
onClipEvent (load) {
    var heartWidth = this._width;
    var heartHeight = this._height;
    this._x = (Math.random()*799 - heartWidth);
    var currentXpos = this._x;
    var shiftLeftInterval = setInterval(shiftright,100);
    function shiftright(){
        this._x = _x + 50;
    }
}
onClipEvent (enterFrame){
    this._y = _y - 1;
}
  1. onClipEvent (load) {
  2.     var heartWidth = this._width;
  3.     var heartHeight = this._height;
  4.     this._x = (Math.random()*799 - heartWidth);
  5.     var currentXpos = this._x;
  6.     var shiftLeftInterval = setInterval(shiftright,100);
  7.     function shiftright(){
  8.         this._x = _x + 50;
  9.     }
  10. }
  11. onClipEvent (enterFrame){
  12.     this._y = _y - 1;
  13. }


I'm trying to shift the movie clip gently from left to right but I can't even get the above code to work (which I thought should shift the movie clip to the right 50 pixels every 100 miliseconds.

Anybody have any tutorials or ideas on how to get this movie clip to shift back and forth smoothly? Also this actionscript is attatched to the actual movie clip itself and the movie clip is not named because I plan on duplicating this movie clip several times.

Finally, I want this movie clip to delete itself after it reaches a certain y postion. I had the following code to do this:
Code: [ Select ]
onClipEvent (enterFrame){
 if (this._y <= 100){
    this.removeMovieClip();
    this.removeMovieClip();
 }
}
  1. onClipEvent (enterFrame){
  2.  if (this._y <= 100){
  3.     this.removeMovieClip();
  4.     this.removeMovieClip();
  5.  }
  6. }


but it wouldn't remove the frame. I could trace things to the window.. but I couldn't remove this instance of the movie clip. Any ideas here?
  • RockmanTV
  • Proficient
  • Proficient
  • RockmanTV
  • Posts: 348

Post 3+ Months Ago

I ended up figuring out a solution. Thanks to all of those who tried.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 14 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.