A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Moving Objects With ActionScript

  1. #1
    Member
    Join Date
    May 2001
    Posts
    31

    Moving Objects With ActionScript

    Hey,

    I think this should be possible, but I have no clue how to do it. I am using regular Flash MX by the way. Here's what I'm trying to accomplish:

    When you click a menu button, it will tell a movie clip to shink and then move off of the screen with an alpha transition. Once the clip is off the screen, I want to execute a simple gotoAndPlay .... but I don't want the gotoAndPlay to execute UNTIL the movie clip is off the screen. Is this even possible? Hope this makes sense. Thanks for your time.

  2. #2
    Abandon all Hope Inflicted's Avatar
    Join Date
    Aug 2003
    Location
    Harlem A+, Netherlands
    Posts
    296
    regards

  3. #3
    Member
    Join Date
    May 2001
    Posts
    31
    Kind of a side question on this, is there anyway to pause action script? To allow time for a movie clip to play or something like that?

  4. #4
    Abandon all Hope Inflicted's Avatar
    Join Date
    Aug 2003
    Location
    Harlem A+, Netherlands
    Posts
    296
    This is a nice example of controlling
    movement with a button:

    code:
    MovieClip.prototype.easeTo = function(tar, tarx, tary) {
    this.onEnterFrame = function() {
    this._xscale += (tar-this._xscale)/5;
    this._yscale = this._xscale;
    this._x += (tarx-this._x)/5;
    this._y += (tary-this._y)/5;
    if (this._x>tarx-1 && this._x<tarx+1 && this._y>tary-1 && this._y<tary+1) {
    delete this.onEnterFrame;
    }
    };
    };
    btn.onRelease = function() {
    box.easeTo(100, 250, 30 );
    };



    Make a button with the instance name "btn", and a MC with the instance name "box". See the magic!
    Code was done by scotty at kirupaforum,
    so he gets all the credit.
    regards

  5. #5
    Member
    Join Date
    May 2001
    Posts
    31
    WOW. This is almost exactly what im looking for, the only adendum would be to have it alpha to 0 as it moves, and then goToAndPlay after the motion is done. As for the code, I have an idea what it does, but I'm not 100% sure.

  6. #6
    Abandon all Hope Inflicted's Avatar
    Join Date
    Aug 2003
    Location
    Harlem A+, Netherlands
    Posts
    296
    code:
    MovieClip.prototype.easeTo = function(tar, tarx, tary) {
    this.onEnterFrame = function() {
    this._xscale += (tar-this._xscale)/5;
    this._yscale = this._xscale;
    this._x += (tarx-this._x)/5;
    this._y += (tary-this._y)/5;
    if (this._x>tarx-1 && this._x<tarx+1 && this._y>tary-1 && this._y<tary+1) {
    delete this.onEnterFrame;
    }
    };
    };
    btn.onRelease = function() {
    fadeout(this);
    box.easeTo(100, 250, 30 );
    };
    this.fadeout = function() {
    box._alpha = 100;
    this.onEnterFrame = function() {
    this._alpha -= 3;
    if (this._alpha<=1) {
    this._alpha = 1;
    }
    };
    };



    Never use goToAndPlay, you have to find that out yourself...
    regards

  7. #7
    The G5 SP N_R_D's Avatar
    Join Date
    Apr 2004
    Posts
    1,118
    why no gotoandplay , and what to use instead?

  8. #8
    Abandon all Hope Inflicted's Avatar
    Join Date
    Aug 2003
    Location
    Harlem A+, Netherlands
    Posts
    296
    That was meant as: I never use...
    What I always do is load swf's externally.
    But I'll try to make something...
    regards

  9. #9
    Member
    Join Date
    May 2001
    Posts
    31
    I came up with a solution. Thanks for the help Inflicted!

  10. #10
    Abandon all Hope Inflicted's Avatar
    Join Date
    Aug 2003
    Location
    Harlem A+, Netherlands
    Posts
    296
    That's the way Wopat55!
    Find a good code, and alter it to
    your own needs!!!
    (you've seen my avatar, haven't you?!)

    good luck
    regards

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